Printf UTF8 characters with printf from hex ints

Kind of a 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 is あ Entity is & # 12353 and its Hex Entity x3041, etc.

But how can I use these two numbers to print all the characters on the command line?

+3
source share
2 answers

If your terminal is configured for UTF-8 and the locale is set correctly, you can write:

char s[]="あ";

you can also try

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

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

+3
source

__STDC_ISO_10646__ , wchar_t , - :

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

Source: https://habr.com/ru/post/1781631/


All Articles