-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_wcharlen.c
60 lines (53 loc) · 1.4 KB
/
ft_wcharlen.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_wcharlen.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ngouy <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/01/30 09:22:01 by ngouy #+# #+# */
/* Updated: 2015/02/13 12:15:51 by ngouy ### ########.fr */
/* */
/* ************************************************************************** */
#include "header.h"
int ft_wcharlen(wchar_t *st)
{
int ret;
ret = 0;
while (st[ret])
ret++;
return (ret);
}
int ft_wchartlen(wchar_t *st)
{
int ret;
int cpt;
ret = 0;
cpt = 0;
while (st[cpt])
{
if (st[cpt] <= 127)
ret++;
else if (st[cpt] <= 2047)
ret += 2;
else if (st[cpt] < 65535)
ret += 3;
else
ret += 4;
cpt++;
}
return (ret);
}
int sst(wchar_t *sstr)
{
int ret;
if (!sstr)
return (0);
ret = 0;
while (*sstr)
{
if (*sstr != '0' || *sstr != ' ')
ret = 1;
}
return (ret);
}