zoukankan      html  css  js  c++  java
  • 简体繁体内码转换API

     public class ANSIConversionAPI
        {
           
            const int SIMPLIFIED_CHINESE = 0x02000000;
            const int TRADITIONAL_CHINESE = 0x04000000;
           
           
           
            [DllImport("kernel32.dll", EntryPoint = "LCMapStringA")]
            public static extern int LCMapString(int Locale, int dwMapFlags, byte[] lpSrcStr, int cchSrc, byte[] lpDestStr, int cchDest);


            public  string BigToGb2312Ex(string str)
            {

                byte[] src = Encoding.GetEncoding(936).GetBytes(str);
                byte[] dest = new byte[src.Length];
                LCMapString(0x0804, SIMPLIFIED_CHINESE, src, -1, dest, src.Length);
                return Encoding.GetEncoding(936).GetString(dest);

            }

            public  string Gb2312ToGigEx(string str)
            {

                byte[] src = Encoding.GetEncoding(936).GetBytes(str);
                byte[] dest = new byte[src.Length];
                LCMapString(0x0804, TRADITIONAL_CHINESE, src, -1, dest, src.Length);
                return Encoding.GetEncoding(936).GetString(dest);
            }


        }

  • 相关阅读:
    九个令人兴奋的新功能将与Java 9 展示两点
    自学前端开发 新版css时钟效果图
    自学前端,你要的学习资料到了~~~~~~
    Angularjs中ng-repeat与移动端滑动插件iScroll的冲突
    计蒜客学习记录
    明明的随机数
    模板题
    泉州一中复赛模拟
    快速幂模板
    NOIP2013
  • 原文地址:https://www.cnblogs.com/neozhu/p/1350274.html
Copyright © 2011-2022 走看看