Home > Back-end >  Be urgent!!!! On Windows: c ofstream utf-8 encoding
Be urgent!!!! On Windows: c ofstream utf-8 encoding

Time:10-17

As shown in figure 1-1, 1-2, file creation, the format for utf-8, written documents, format into the ANSI, how do I remain the same, still is: utf-8.


String strFile="c: \ \ utf-8 test11. TXT".

//step1: creating utf-8 files
The FILE * fp=fopen (strFile c_str (), "w, CCS=utf-8");//the new file
Assert (fp!=NULL);
The fclose (fp);

//step2: written content
STD: : fstream fout.
Fout. Open (strFile. C_str (), STD: : ios_base: : _Nocreate | STD: : ios_base: : out);//by default, speaking, reading and writing, normal file
Fout & lt; <"China";
Fout. Close ();
//step3: file save as, coding format for: ANSI, why

CodePudding user response:

Google "fstream utf-8"
http://mariusbancila.ro/blog/2008/10/20/writing-utf-8-files-in-c/
  • Related