最近被汉字的unicode码搞得头大。
用string从记事本里获取了汉字以后想要得到他的unicode码就那么难?
网上找了半天再加各种改才出来。把自己的贴出来吧
ifstream readfile ("test.txt");//读取文件
if (! readfile.is_open())
{ cout << "Error opening file"; exit (1); }//文件打开失败提示
while(getline(readfile,s,','))
{
xx= const_cast<char*>(s.c_str());
int dwNum = MultiByteToWideChar(CP_ACP, 0, xx, -1, NULL, 0);//dwNum确认转换需要的字符长度(包括了结束符”)
wchar_t *wstr = (wchar_t*)malloc(sizeof(wchar_t) * dwNum);//wstr存的unicode码包括换行的'10'
MultiByteToWideChar (CP_ACP, 0, xx, -1, wstr, dwNum); //多字节字符转宽字符(Unicode)
//wstr即存储的取出来的unicode码
}
最后附上帮助很大的一片文章。
http://www.chengxy.com/article/14017.html