X
xmllmx
4 lines of code are worth a thousand words.
wofstream fout("test.txt", ios:ut|ios::trunc);
fout.imbue(locale(locale::classic(), new codecvt_utf16<wchar_t,
0x10FFFFUL, little_endian>)); // UTF-16LE
fout << L'\n';
fout.close();
// Compiled with VC++ 2010 that supports C++0x.
Please note that the file is opened in unicode text mode. Because
fout.close() will automatically replace every LF with CR-LF, So,
test.txt now should hold 4 bytes which are 0x0D, 0x00, 0x0A, 0x00.
However, test.txt should just hold 3 bytes which are 0x0D, 0x0A, 0x00.
Notepad will fail to recognize this file.
Is this really a BIG bug?
wofstream fout("test.txt", ios:ut|ios::trunc);
fout.imbue(locale(locale::classic(), new codecvt_utf16<wchar_t,
0x10FFFFUL, little_endian>)); // UTF-16LE
fout << L'\n';
fout.close();
// Compiled with VC++ 2010 that supports C++0x.
Please note that the file is opened in unicode text mode. Because
fout.close() will automatically replace every LF with CR-LF, So,
test.txt now should hold 4 bytes which are 0x0D, 0x00, 0x0A, 0x00.
However, test.txt should just hold 3 bytes which are 0x0D, 0x0A, 0x00.
Notepad will fail to recognize this file.
Is this really a BIG bug?