0

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

我将其追溯到wctomb不知道如何处理例如 UTF-16 字符 8240 的函数:

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

如何设置使用的语言环境wctomb,例如“所有 unicode 字符”?

如何从我需要的字符开始找到我需要的正确语言环境名称?

4

1 回答 1

2

设置正确的 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

于 2011-01-27T13:09:23.793 回答