CString sUCode=_T("00D7");
TCHAR* pStop = NULL;
wchar_t wc = (short)_tcstol(sUCode, &pStop, 16);
CString str;//如何将00D7转换成字符串"×"
TCHAR* pStop = NULL;
wchar_t wc = (short)_tcstol(sUCode, &pStop, 16);
CString str;//如何将00D7转换成字符串"×"
CString str;
str.Insert(0, wc);
TCHAR* pStop = NULL;
wchar_t wc = (short)_tcstol(sUCode, &pStop, 16);
CString str;//如何将00D7转换成字符串"×"
str.Format(L"%c",wc);
d:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\atlmfc\include\cstringt.h(2245) : 参见“ATL::CStringT”的声明
with
[
BaseType=char,
StringTraits=StrTraitMFC_DLL<char>,
t_bMFCDLL=true
]
and
[
BaseType=char,
t_bMFCDLL=true
]
与指向的类型无关;转换要求 reinterpret_cast、C 样式转换或函数样式转换
不是str.Format(L'%c',wc);
会报c2664错误,
写成str.Format(L'%c',wc);
显示是空值.
这样吧
你这个CString的char_type是char
于是这样的CString就不会正确的存unicode了。
用CStringW吧,要是没定义你看看atlstr.h头文件,那里根据环境定义了好几种
字符 => 16进制
sscanf(s, "%x", &hex_val);16进制 =〉字符
sprintf(s, "0x%x", hex_val);
宽字节使用wsscanf、wsprintf。不知是不是楼主想要的。
你的工程中默认用的是多字节,于是CString里的字符串类型是char,char是存储不了wchar_t的。
问题解决了,多谢两位大侠.