-
Notifications
You must be signed in to change notification settings - Fork 2
/
ft_putnwstr.c
33 lines (30 loc) · 1.17 KB
/
ft_putnwstr.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_putnwstr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rlambert <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/01/27 17:55:45 by rlambert #+# #+# */
/* Updated: 2015/02/26 14:21:22 by roblabla ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_putnwstr(const wchar_t *str, size_t len)
{
size_t i;
i = 0;
while (*str && i < len)
{
if (*str <= 0x7F)
i++;
else if (*str <= 0x7FF)
i += 2;
else if (*str <= 0xFFFF)
i += 3;
else if (*str <= 0x10FFFF)
i += 4;
if (i <= len)
ft_putwchar(*str++);
}
}