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;
 }

你可能感兴趣的:(C#-获取字符的GBK编码值)