用write打印Unicode

时间:2019-02-26 11:54:49

标签: c unicode

我不明白为什么我的Unicode字符不显示在屏幕上。我正在重新编码printf函数(以学习)。

static void     print_unicode(wchar_t c)
{
    write(1, &c, 4);
}

int     c_format(va_list *v1, char *options, char format)
{
    char        c;
    wchar_t     uc;
    int     count;
    t_bool  unicode;

    uc = 0;
    unicode = check_flags(options, "l");
    if (format == '%')
        c = '%';
    else if (unicode)
        uc = (wchar_t)va_arg(*v1, unsigned int);
    else
        c = (char)va_arg(*v1, int);
    count = 1;
    display_padding(options, &count, 1);
    if (unicode)
        print_unicode(uc);
    else        
        ft_putchar(c);
    display_padding(options, &count, 0);
    return (count);
}

堆栈上的Unicode字符为wchar_t nb1 = L'ሴ';,环境为Linux。

0 个答案:

没有答案