Вероятно, лучше по разным причинам записывать данные в виде CString, но если вам нужно преобразовать вашу String (m_sString) в символьную строку ASCII, возможно, что-то подобное будет работать для вас ...
void myclass::Serialize(CArchive & ar)
{
CHAR* buf;
DWORD len;
if (ar.IsStoring()) // Writing
{
len = m_sString.GetLength(); // Instead of null terminated string, store size.
ar << len;
buf = (CHAR*)malloc(len);
WideCharToMultiByte(CP_UTF8, 0, m_sString, len, buf, len, NULL, NULL); // Convert wide to single bytes
ar.Write(buf, len); // Write ascii chars
free(buf);
}
else // Reading
{
ar >> len;
buf = (CHAR*)malloc(len);
ar.Read(buf, len); // Read ascii string
MultiByteToWideChar(CP_UTF8, 0, buf, len, m_sString.GetBufferSetLength(len), len); // Convert ascii bytes to CString wide bytes
free(buf);
}
}