开发者

printf UTF8 characters with printf from Hexadecimal ints

Kind of trivial thing but ... I want to print japanese characters using plain C from Hexadecimals

From this table, I know that, the first char in the table, あ's Entity is &# 12353 and its Hex Entity is x3041, etc.

But how do I use this two numbers in order to get printed all characters in the command开发者_如何学C line?


If your terminal is set to UTF-8 and locale is set correctly, you may write:

char s[]="あ";

you can also try

 char s[]={0xe3,0x81,0x82,0x0}

(the last is the Unicode UTF-8 encoding for "あ"), and then just printf("%s",s);


If __STDC_ISO_10646__ is defined, wchar_t is in Unicode, and you can do something like:

printf("%lc", (wchar_t)0x3041);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜