用CMarkup类,读入XML文件,读入的中文为乱码,请教怎样解决
用CMarkup类,读入XML文件,读入的中文为乱码,请问怎样解决?
谢谢
------解决方案--------------------
你看看你的XML文件的编码方式,以及你文件存储的方式是否正确。
------解决方案--------------------
bool Load( LPCTSTR szFileName );
你用这个函数
或者
改这块
// Windows Unicode file is detected if starts with FEFF
if ( pBuffer[0] == 0xff && pBuffer[1] == 0xfe )
{
// Contains byte order mark, so assume wide char content
// non _UNICODE builds should perform UCS-2 (wide char) to UTF-8 conversion here
csText = (LPCWSTR)(&pBuffer[2]);
csNotes += _T( "File starts with hex FFFE, assumed to be wide char format. ");
}
else
{
// _UNICODE builds should perform UTF-8 to UCS-2 (wide char) conversion here
csText = (LPCSTR)pBuffer;
}
这里,UTF-8的解码过程是错误的
谢谢
------解决方案--------------------
你看看你的XML文件的编码方式,以及你文件存储的方式是否正确。
------解决方案--------------------
bool Load( LPCTSTR szFileName );
你用这个函数
或者
改这块
// Windows Unicode file is detected if starts with FEFF
if ( pBuffer[0] == 0xff && pBuffer[1] == 0xfe )
{
// Contains byte order mark, so assume wide char content
// non _UNICODE builds should perform UCS-2 (wide char) to UTF-8 conversion here
csText = (LPCWSTR)(&pBuffer[2]);
csNotes += _T( "File starts with hex FFFE, assumed to be wide char format. ");
}
else
{
// _UNICODE builds should perform UTF-8 to UCS-2 (wide char) conversion here
csText = (LPCSTR)pBuffer;
}
这里,UTF-8的解码过程是错误的