我正在尝试打印一堆单元标签;其中一些包含希腊字符,有些则具有其他有趣的代码点。

我将其追溯到 wctomb 功能不知道该如何处理EG UTF-16字符8240:

char mb[10]; 
assert( 0 <= wctomb(mb,8240) );

我如何设置由 wctomb 例如“所有Unicode字符”?

从我需要的字符开始,我如何找到所需的适当的语言名称?

有帮助吗?

解决方案

设置正确的UTF-8语言环境将修复它;

#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <locale.h>

int main()
{
    setlocale(LC_ALL, "en_US.UTF-8");
    char mb[10]; 
    assert( 0 <= wctomb(mb,8240) );
    printf("%s\n", mb);
    return 0;
}

http://ideone.com/sflzj

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top