vc gbk转big5
void GBKSimplified2GBKTraditional(LPTSTR szSimplified)
{
LCID dwLocale;
WORD wLangID;
wLangID=MAKELANGID(LANG_CHINESE,SUBLANG_CHINESE_SIMPLIFIED);
dwLocale=MAKELCID(wLangID,SORT_CHINESE_PRC);
int nLength;
char *pBuffer;
nLength=LCMapString(dwLocale,LCMAP_TRADITIONAL_CHINESE,(LPCTSTR)szSimplified,strlen(szSimplified),NULL,0);
pBuffer=new char[nLength+1];
pBuffer[nLength]=0;
LCMapString(dwLocale,LCMAP_TRADITIONAL_CHINESE,(LPCTSTR)szSimplified,strlen(szSimplified),pBuffer,nLength);
strcpy(szSimplified,pBuffer);
delete(pBuffer);
return;
}
//WCHAR 转换成 CHAR函数
void ConvertUnicodeToAnsi(WCHAR * Source,char * obj)
{
DWORD dwNum = WideCharToMultiByte(950,NULL,Source,-1,NULL,0,NULL,FALSE);
WideCharToMultiByte (950,NULL,Source,-1,obj,dwNum,NULL,FALSE);
}
//CHAR TO WCHAR
void ConvertAnsiTounicode(char * source,WCHAR *obj)
{
int nLength = 0;
nLength = MultiByteToWideChar(CP_ACP,0,source,-1,NULL,0);
MultiByteToWideChar(CP_ACP,0,source,-1,obj,nLength);
}
void CConvertDlg::OnButton1()
{
// TODO: Add your control notification handler code here
char p[200]={0};
strcpy(p,"语言");
WCHAR buf[200]={0};
GBKSimplified2GBKTraditional(p);
ConvertAnsiTounicode(p,buf);
strcpy(p,"");
ConvertUnicodeToAnsi(buf,p);
}
原理:
1.str 转GBK繁体
2.str 转UNICODE
3.STR 转BIG5