CString で保存される形式
UNICODE | FF FE FF | 04 | 32 00 | 30 00 | 31 00 | 30 00 |
MBCS | 04 | 32 | 30 | 31 | 30 |
// VC98\MFC\SRC\ArcCore.cpp
// CString serialization code
// String format:
// UNICODE strings are always prefixed by 0xff, 0xfffe
// if < 0xff chars: len:BYTE, TCHAR chars
// if >= 0xff characters: 0xff, len:WORD, TCHAR chars
// if >= 0xfffe characters: 0xff, 0xffff, len:DWORD, TCHARs
CArchive& AFXAPI operator<<(CArchive& ar, const CString& string)
{
// special signature to recognize unicode strings
#ifdef _UNICODE
ar << (BYTE)0xff;
ar << (WORD)0xfffe;
#endif
if (string.GetData()->nDataLength < 255) {
ar << (BYTE)string.GetData()->nDataLength;
}
else if (string.GetData()->nDataLength < 0xfffe) {
ar << (BYTE)0xff;
ar << (WORD)string.GetData()->nDataLength;
}
else {
ar << (BYTE)0xff;
ar << (WORD)0xffff;
ar << (DWORD)string.GetData()->nDataLength;
}
ar.Write(string.m_pchData, string.GetData()->nDataLength*sizeof(TCHAR));
return ar;
}