c - fprintf() issues utf-8 linux -


Well, I've got to print UTF-8 encoded characters to the terminal. But the printing on the file is not working as I expected such as using wchar.h and locale.h:

  #include & lt; Locale.h & gt; # Include & lt; Wchar.h & gt; Int main () {catalocell (lc_ol, ""); Wint_t index = 0; FILE * fpinout = fopen ("UTF-8.txt", "w"); (; Index & LT; 0x200; index = 0 index ++) of {printf ( "% i: \ t% LC \ n", index, index) to; // works fine, print utf-8 characters for the terminal fprintf (fpinout, "% i \ t% lc", index, index); // does not work, output is quirky fclose (fpinout); }  

I tried to use the index, such as wint_t and wchar_t my UTF-8.txt file looks like this:

  and ㄀ C L㌂̉lah 㔄 ԉ term 㜆 ܉ Number 㤈 U〱 ਉ ㄱ ଉ㈱ ఉ㌱ ഉ 㐱 ฉ 㔱 ༉ 㘱 ဉ 㜱 ᄉ 㠱 ሉ 㤱 ጉ〲 ᐉ ㄲ ᔉ㈲ᘉ㌲ᜉ 㐲᠉ 㔲 ᤉ 㘲 ᨉ 㜲 ᬉ 㠲 ᰉ㤲 ᴉ〳ḉ ㄳ Ἁ㈳ ㌳ ℉ 㐳 ∉ 㔳 ⌉ 㘳 ␉ 㜳 ┉ 㠳 ☉ 㤳 ✉〴⠉ ㄴ ⤉㈴⨉㌴⬉ 㐴 Ⰹ 㔴 კ 㘴 ⸉ 㜴 ⼉ 㠴> 㤴 ㄉ 〵 ㈉ ㄵ ㌉㈵ 㐉 ㌵ 㔉 㐵㘉 㔵 㜉 㘵 㠉 㜵 㤉 㠵 㨉 㤵 㬉 〶 㰉 ㄶ 㴉 ㈶ 㸉 ㌶ 㼉 㐶 䀉 㔶 䄉 㘶 䈉 㜶 䌉 㠶 䐉 㤶 䔉 〷 䘉 ㄷ 䜉 ㈷ 䠉 ㌷ 䤉 㐷 䨉 㔷 䬉 㘷 䰉 㜷 䴉 㠷 三 㤷伉 〸 倉 ㄸ 儉 ㈸ 刉 ㌸ 匉 㐸 吉 㔸 唉 㘸 嘉 㜸 圉 㠸 堉 㤸 変 〹 娉 ㄹ 嬉 ㈹ 尉 ㌹ 崉 㐹 帉 㔹 弉 㘹 怉㜹 愉 㠹 戉 㤹 按 〱 and ㅤ ㄰ 攉 〱 L'ㅦ ㌰ 有 〱 Lah ㅨ 㔰 椉 〱 term ㅪ 㜰 欉 〱 Number ㅬ 㤰 洉 ㄱ and ㅮ ㄱ 漉 ㄱ L'ㅰ ㌱ 焉 ㄱ Lah ㅲ 㔱 猉 ㄱ term ㅴ 㜱甉 ㄱ Number ㅶ 㤱 眉 ㈱r ㅸ ㄲ 礉 ㈱l ㅺ ㌲ 笉 ㈱lah ㅼ 㔲 紉 ㈱s ㅾ 㜲 缉 ㈱s 胂 ㈱h 臂 ㌱r 苂 ㌱rh 菂 ㌱l 蓂 ㌱la 藂 ㌱ Lah 蛂 ㌱v 蟂㌱s 裂 ㌱s 观 ㌱s 諂 ㌱h 诂 㐱 and 賂 㐱 is `跂 㐱 L'軂 㐱 G 迂 㐱 Lah 郂 㐱 and 釂 㐱 term 鋂 㐱 men 鏂 㐱 Number 铂 㐱 are 闂 㔱 and 雂 㔱 is` 韂 㔱 L飂 㔱 G 駂 㔱 Lah 髂 㔱 and 鯂 㔱 term 鳂 㔱 men 鷂 㔱 Number 黂 㔱 H鿂 㘱 and ꃂ 㘱 is `ꇂ 㘱 L'ꋂ 㘱 G ꏂ 㘱 Lah ꓂ 㘱 Vꗂ 㘱 Sꛂ 㘱 SꟂ 㘱 Sꣂ 㘱 H꧂ 㜱Rꫂ 㜱 Rhꯂ 㜱 L'곂 㜱 G 귂 㜱 Lah 껂 㜱 and 꿂 㜱 term 냂 㜱 men 뇂 㜱 Number 닂 㜱 are 돂 㠱 and 듂 㠱 is `뗂 㠱 L'뛂 㠱 G 럂 㠱 G 룂 㠱 and 맂 㠱 term 뫂 㠱 men 믂 㠱 Number 볂 㠱 are 뷂 㤱 and 뻂 㤱 is `뿂 㤱 L'胃 㤱 G 臃 㤱 Lah 苃 㤱 and 菃 㤱 term 蓃 㤱 men 藃 㤱 Number 蛃 㤱 are 蟃 〲 and 裃 〲 is `觃 〲 L'諃 〲 G 诃 〲 Lah 賃 〲 and 跃 〲 term 軃 〲 men 迃 〲 Number 郃 〲 are 釃 ㄲ and 鋃 ㄲ is` 鏃 ㄲ L'铃 ㄲ G 闃 ㄲ Lah 雃 ㄲ and 韃 ㄲ term 飃 ㄲ men 駃ㄲ Number 髃 ㄲ are 鯃 ㈲r 鳃 ㈲rh 鷃 ㈲l 黃 ㈲la鿃㈲lah ꃃ㈲ and ꇃ㈲ term ꋃ㈲ men ꏃ㈲ Number ꓃㈲ Hꗃ㌲rꛃ㌲rhꟃ㌲ Lꣃ㌲la ꧃㌲lah꫃㌲vꯃ ㌲s 곃 ㌲s 귃 ㌲s 껃 ㌲h 꿃 㐲 and 냃 㐲 is `뇃 㐲 L'닃 㐲 G 돃 㐲 Lah 듃 㐲 and 뗃 㐲 term 뛃 㐲 men 럃 㐲 Number 룃 㐲 are 맃 㔲 and 뫃 㔲 Raw 믃 㔲 L 볃 㔲 뷃 㔲 㔲 뻃 㔲 뿃  

Any help is appreciated.

The way you write will help you open the file in UTF-32 binary mode of fact will UTF32LE .

You should use the change in UTF8 encoding. Either ICU library or note Use wctomb / wctombs / wclen c function () that wctomb * functions typically depend on locale (if you have a Greek locale often will not work correctly)

< / Div>

Comments

Popular posts from this blog

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -