• 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
  • 相关阅读:
    MATLAB 粒子群优化PSO
    MATLAB 简单图像融合
    MATLAB 拉普拉斯残差金字塔
    MATLAB 随机抽样一致RANSAC
    MATLAB TV模型图像修复
    MATLAB radon变换
    MATLAB 二维直方图
    MATLAB 自适应中值滤波RAMF
    MATLAB 二值图像内外边界跟踪
    MATLAB 各向异性扩散)
  • 原文地址:https://www.cnblogs.com/ahuo/p/1018703.html
Copyright © 2020-2023  润新知