Unicode 环境下的字符串的操作

1.CString转int

int i _ttoi( str );

2.保存中文和读取中文:

CSdtioFile在Unicode环境下默认是不支持中文的,若需要存储和读取中文需要设置代码页:

#include "locale.h"

::_wsetlocale( LC_ALL, _T("chs") ); // 设置当前代码页支持中文
stdFile.WriteString( ss );
::_wsetlocale( LC_ALL, _T("") ); // 恢复默认代码页

3.CString转char*

char* psText;

CString strScr = "234wo”;

DWORD dlgVideoList::WideChagetoBY( CString strScr , char * psText)
{
DWORD dwNum = WideCharToMultiByte(CP_OEMCP,NULL,strScr,-1,NULL,0,NULL,FALSE);
WideCharToMultiByte (CP_OEMCP,NULL,strScr,-1,psText,dwNum,NULL,FALSE);
return dwNum;
}

posted @ 2013-11-26 17:34  友琼  阅读(240)  评论(0编辑  收藏  举报