Commit 9b54ad29 authored by Gabriel Genois's avatar Gabriel Genois

wchart is now working

parent eaae80de
Pipeline #93 failed with stages
in 14 seconds
......@@ -27,8 +27,10 @@ typedef struct s_pfdata
void ftpf_tmp_printpfdata(t_pfdata **dt);
int ftpf_getwcharlen(wchar_t wchar);
char *ftpf_charfromwchar(wchar_t wchar);
char *ftpf_strings_null(void);
int ft_lstfromwchar(t_pfdata **pfdata, wchar_t **item);
int ft_lstfromwchar(t_pfdata **pfdata, wchar_t *item);
void ftpf_width(t_pfdata **dt, va_list *data, int *pos);
void ftpf_flags_widecheck(t_pfdata **dt);
void ftpf_flags(t_pfdata **dt, int *pos);
......
......@@ -6,7 +6,7 @@
/* By: ggenois <ggenois@student.le-101.fr> +:+ +: +: +:+ */
/* #+# #+ #+ #+# */
/* Created: 2018/05/19 16:03:09 by ggenois #+# ## ## #+# */
/* Updated: 2018/11/04 00:34:52 by ggenois ### #+. /#+ ###.fr */
/* Updated: 2018/11/04 14:50:23 by ggenois ### #+. /#+ ###.fr */
/* / */
/* / */
/* ************************************************************************** */
......@@ -182,36 +182,9 @@ int main(int argc, char **argv)
//i = ft_printf("@moulitest: %.x %.0x", 0, 0);
//i = ft_printf("Je suis un printf");
//i = ft_printf("%.2s is a string", "");
//i = ft_printf("%s is a string", "");
int lol;
lol = L'米';
char *hexa;
wchar_t out;
hexa = ft_itoa_base(lol, 16);
out = hexa;
write(1, &out, 20);
unsigned long long int *te;
//te[0] = '\u7C73';
//te = te + lol;
char *tt;
//write(1, "\u7C73", 4);
i = ft_printf("\n%S", L"米");
//i = ft_printf("\n%S", NULL);
//i = ft_printf("%S%S%S%S%S%S%S%S%S%S%S%S%S%S%S%S%S%S%S%S%S%S%S%S%S", L"Α α", L"Β β", L"Γ γ", L"Δ δ", L"Ε ε", L"Ζ ζ", L"Η η", L"Θ θ", L"Ι ι", L"Κ κ", L"Λ λ", L"Μ μ", L"Ν ν", L"Ξ ξ", L"Ο ο", L"Π π", L"Ρ ρ", L"Σ σ", L"Τ τ", L"Υ υ", L"Φ φ", L"Χ χ", L"Ψ ψ", L"Ω ω", L"");
i = ft_printf("\n%D", 9223372036854775807);
ft_putchar('\n');
ft_putnbr(i);
}
......
......@@ -6,7 +6,7 @@
/* By: ggenois <ggenois@student.le-101.fr> +:+ +: +: +:+ */
/* #+# #+ #+ #+# */
/* Created: 2018/05/19 16:07:38 by ggenois #+# ## ## #+# */
/* Updated: 2018/09/06 16:49:44 by ggenois ### #+. /#+ ###.fr */
/* Updated: 2018/11/04 14:50:17 by ggenois ### #+. /#+ ###.fr */
/* / */
/* / */
/* ************************************************************************** */
......
......@@ -3,61 +3,78 @@
char *ftpf_strings_null(void)
{
char *s;
const char *ntext = "(null)";
s = ft_strnew(7);
ft_memcpy(s, "(null)", 7);
ft_memcpy(s, ntext, 7);
return (s);
}
t_list *ftpf_lstnew_w(wchar_t *data)
int ftpf_getwcharlen(wchar_t wchar)
{
t_list *item;
item = (t_list *) malloc(sizeof(t_list));
item->content = (wchar_t*) malloc(sizeof(wchar_t));
item->content = data;
item->content_size = sizeof(wchar_t);
return (item);
if (wchar <= 0x7f)
return (1);
else if (wchar <= 0x7ff)
return (2);
else if (wchar <= 0xffff)
return (3);
else
return (4);
}
/*
char *ftpf_convertwchar(wchar_t *input)
char *ftpf_charfromwchar(wchar_t wchar)
{
int nbr;
char *output;
const char prefix = "\\u";
char *tmp;
nbr = (*input);
tmp = ft_itoa_base(nbr, 16);
output = ft_strjoin(prefix, tmp);
free(tmp);
return (output);
char *str;
int i;
int wsize;
i = 0;
wsize = ftpf_getwcharlen(wchar);
str = ft_strnew(wsize + 1);
if (wsize == 1)
str[i++] = wchar;
else if (wsize == 2)
{
str[i++] = (wchar >> 6) + 0xC0;
str[i++] = (wchar & 0x3F) + 0x80;
}
else if (wsize == 3)
{
str[i++] = (wchar >> 12) + 0xE0;
str[i++] = ((wchar >> 6) & 0x3F) + 0x80;
str[i++] = (wchar & 0x3F) + 0x80;
}
else
{
str[i++] = (wchar >> 18) + 0xF0;
str[i++] = ((wchar >> 12) & 0x3F) + 0x80;
str[i++] = ((wchar >> 6) & 0x3F) + 0x80;
str[i++] = (wchar & 0x3F) + 0x80;
}
return (str);
}
*/
int ft_lstfromwchar(t_pfdata **dt, wchar_t **item)
int ft_lstfromwchar(t_pfdata **dt, wchar_t *item)
{
int ilenght;
int ilenghtbck;
int ilenght;
char *buffer;
ft_putstr("Entering ft_lstfromwchar");
ilenght = 0;
//ftpf_convertwchar(&(*item)[0]);
write(1, &(*item)[0], 4);
while ((*item)[ilenght] != L'\0')
if(!item)
{
ft_putstr("T");
ilenght++;
buffer = ftpf_strings_null();
ft_lstfromstr(&(*dt)->data, &buffer);
free(buffer);
return (-1);
}
ilenghtbck = ilenght;
while (--ilenght > 0)
else
while ((*(item++)))
ilenght++;
while (ilenght-- >= 0)
{
ft_putstr("[--]");
ft_lstadd(&(*dt)->data, ftpf_lstnew_w(&(*item)[ilenght]));
buffer = ftpf_charfromwchar((*(--item)));
ft_lstfromstr(&(*dt)->data, &buffer);
free(buffer);
}
return (ilenghtbck);
return (ilenght);
}
\ No newline at end of file
......@@ -6,7 +6,7 @@
/* By: ggenois <ggenois@student.le-101.fr> +:+ +: +: +:+ */
/* #+# #+ #+ #+# */
/* Created: 2018/05/19 16:09:47 by ggenois #+# ## ## #+# */
/* Updated: 2018/11/03 23:02:50 by ggenois ### #+. /#+ ###.fr */
/* Updated: 2018/11/04 14:27:53 by ggenois ### #+. /#+ ###.fr */
/* / */
/* / */
/* ************************************************************************** */
......@@ -16,31 +16,18 @@
int ftpf_strings_w(t_pfdata **dt, va_list *data)
{
wchar_t c;
wchar_t *s;
char *tmp;
int l;
char *tmp;
l = 1;
if ((*dt)->t == 'C' || (*dt)->t == 'c')
{
c = va_arg((*data), wchar_t);
ft_lstadd(&(*dt)->data, ft_lstnew(&c, sizeof(wchar_t)));
tmp = ftpf_charfromwchar(c);
ft_lstfromstr(&(*dt)->data, &tmp);
free(tmp);
}
else if ((*dt)->t == 'S' || (*dt)->t == 's')
{
s = va_arg((*data), wchar_t *);
if (s == NULL)
{
tmp = ftpf_strings_null();
ft_lstfromstr(&(*dt)->data, &tmp);
free(tmp);
}
else
{
l = ft_lstfromwchar(dt, &s);
}
}
l = ft_lstfromwchar(dt, va_arg((*data), wchar_t *));
return (l);
}
......
No preview for this file type
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment