Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试打印一堆单位标签;其中一些包含希腊字符,一些包含其他有趣的代码点。
我将其追溯到wctomb不知道如何处理例如 UTF-16 字符 8240 的函数:
wctomb
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