简体   繁体   中英

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 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);

如果定义了__STDC_ISO_10646__ ,则wchar_t采用Unicode,您可以执行以下操作:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM