Source: carchive::writestring processing Unicode string data
If you want your program to write the data in a file while processing the data, consider using CArchive,jx8net here to write a simple piece of code:
CArchive:: << CString writes the length of the string before writing to the string.
If it is a Unicode string, the encoding "FF FE" is written before each CString, and then the string length is written, and the string is finally written.
The string length value written is encoded, adding some redundancy for the purpose of self explanatory.
Therefore, if you write the csting to the file with <<, you must use >> to read it correctly.
Carchive::writestring (LPCTSTR) is used to write a line of text, so you need to write an \ n After you finish writing plain text.
Carchive::readstring (LPCTSTR) and writestring pair, used to read a line of text, when the characters will be discarded.