This topic has been archived. It cannot be replied.
-
工作学习 / 专业技术讨论 / 汉字代码转换(unicode/ascii)求助汉字在word里面的存放格式是unicode, 而在notepad里面存放的是ascii格式,比如“汉字文件”,unicode是:49 6C 57 5B 87 65 F6 4E,ascii格式是:BA BA D7 D6 CE C4 BC FE。我现在需要在VC++程序里面实现把unicode转换为ascii代码,有没有简单的办法可以实现?请指点。谢谢!
-nw168(新手);
2006-11-24
{255}
(#3339251@0)
-
Not sure how, but i found this --->
-canadiantire(轮胎-pax et lux);
2006-11-24
(#3339454@0)
-
最简单的是使用ATL的CW2A宏#include <altconv.h>
LPCWSTR pszWideChar = L("汉字文件");
CW2A strMultiByte(pszWideChar);
LPCSTR pszMultiByte = strMultiByte;
// and here you go. the buffer hold by strMultiByte will be freed when it goes out of scope.
if you want to try the code, make sure that you saved the .cpp file as GB2132 (don't save it as unicode).
-dpff(dpff);
2006-11-24
{336}
(#3339466@0)
-
C++彻底的做法用IBM ICU(International Components for Unicode)。很复杂。不清楚有没有简单的workaround。Java简单得多,supported natively。
-dusk(~小桥~流水~);
2006-11-24
(#3339491@0)
-
需要font转换。microsoft的部分我不懂,其他OS上一般是通过font point size 在不同的font( charset)之间转换。
-frankwoo(柳五随风);
2006-11-24
(#3340416@0)