把 GB2312 编码转成汉字

论坛 期权论坛 编程之家     
选择匿名的用户   2021-6-2 17:56   1503   0
把 GB2312 编码转成汉字

string s = Convert.ToString(47524, 2); // 转成二进制
byte byte1 = Convert.ToByte(s.Substring(0, 8), 2);
byte byte2 = Convert.ToByte(s.Substring(8), 2);
byte[] array = new byte[2] { byte1, byte2 };
MessageBox.Show(System.Text.Encoding.GetEncoding("GB2312").GetString(array));


汉字获取 GB2312 编码
byte[] array = System.Text.Encoding.GetEncoding("GB2312").GetBytes("工");
string s1 = Convert.ToString(array[0], 16);
string s2 = Convert.ToString(array[1], 16);
int i = Convert.ToInt32(s1 + s2, 16);
MessageBox.Show(i.ToString());
分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:3875789
帖子:775174
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP