谢谢
解决方案 »
- VC++图像处理求教
- _RecordSetPtr如何将XML导回数据库
- [求助,急!]LoadLibrary后紧接着再FreeLibrary会给出一个释放堆错误。
- 刚收到骗子短信,不知道怎么处理
- 请问一下VC下的XML解析需要的环境?
- VC6中,如何制作分隔线?
- 如何获知组合框内容改变
- COM 本质论 最后一个例子COMCHAT能不能运行啊?
- socket 中的send(s,buffer,length,flags)中的length会发送给服务器作为较证吗?
- 关于GetLastError()的问题
- 100分求UTF8如何转成GB2312原码!
- 怎么把GB码和Big5码转换为Unicode代码,只能用查表法
int unicodeLen=MultiByteToWideChar(sourceCodepage,0,str,-1,NULL,0);
wchar_t * pUnicode;
pUnicode=new wchar_t[unicodeLen+1];
memset(pUnicode,0,(unicodeLen+1)*sizeof(wchar_t));
MultiByteToWideChar(sourceCodepage,0,str,-1,(LPWSTR)pUnicode,unicodeLen);
MultiByteToWideChar(936,0,str,-1,(LPWSTR)pUnicode,unicodeLen);
int unicodeLen=MultiByteToWideChar(sourceCodepage,0,str,-1,NULL,0);
wchar_t * pUnicode;
pUnicode=new wchar_t[unicodeLen+1];
memset(pUnicode,0,(unicodeLen+1)*sizeof(wchar_t));
MultiByteToWideChar(sourceCodepage,0,str,-1,(LPWSTR)pUnicode,unicodeLen);
MultiByteToWideChar(936,0,str,-1,(LPWSTR)pUnicode,unicodeLen);
int widecharlen=MultiByteToWideChar( //计算从Ansi转换到Unicode后需要的字节数 CP_ACP, MB_COMPOSITE, (char*)p, //要转换的Ansi字符串 -1, //自动计算长度 0, 0 );; CString tmpstr;; tmpstr.GetBuffer(widecharlen);; //为转换后保存Unicode字符串分配内存 MultiByteToWideChar( //从Ansi转换到Unicode字符 CP_ACP, MB_COMPOSITE, (char*)p, -1, tmpstr.GetBuffer(widecharlen), //转换到tmpstr widecharlen //最多转换widecharlen个Unicode字符 );;
#include "comdef.h"
第二步:
char *str1="了";
_bstr_t str=str1;
WCHAR *str2=str;
第三步:str2就是你要的Unicode