1./u-> Chinese: Convert the 16 binary in the back of/U to 10, then assign to Wchar_t/byte;2. Chinese->/u:3. Utf-8: Utf-8 w/o BOM: No BOM header utf-8:3-byte BOM header, EFBBBF (utf-16 header: FFFE), belongs to Unicode encoding format;
1 //determine if there is a BOM header, and if so, remove the bow head and save it. 2 stringStrval;3 stringstrpath =cstringhelper::unicode2acsii (Cprochelper::getcurrentprocesspath ());4strpath + ="\\test_utf8.txt";5 Ifstream IFS (STRPATH.C_STR (), ios::binary);6 if(Ifs.is_open ())7 {8 StringStream SS;9SS <<ifs.rdbuf ();TenStrval =ss.str (); One ifs.close (); A - //determine if there is a head - //BOM head: EFBBBF the BOOLb =false; - if(0xEF== (byte) strval.at (0) && - 0xBB== (byte) strval.at (1) && - 0xBF== (byte) strval.at (2)) + { -b =true; + } A at //turn around. -Strval = Strval.substr (3, Strval.length ()-3); - - stringStrPath2 =cstringhelper::unicode2acsii (Cprochelper::getcurrentprocesspath ()); -StrPath2 + ="\\test_utf8_bk.txt"; - ofstream ofs (strPath2, ios::binary); in if(Ofs.is_open ()) - { toOFS <<Strval; + ofs.close (); - } the}
Encoding format (to be continued ...) )