C#-获取字符的GBK编码值


public static int GetGBKValue(string key)
 {
            byte[] gbk = Encoding.GetEncoding("GBK").GetBytes(key);
            string code = "";
            foreach (byte b in gbk)
            {
                code += string.Format("{0:X2}", b);
            }
            int gbkValue = int.Parse(code, NumberStyles.HexNumber);
            return gbkValue;
 }

posted @ 2018-01-01 22:00  李国宝  阅读(10378)  评论(0编辑  收藏  举报