try { char chr = textBox1.Text[0]; byte[] gb2312_bt = Encoding.GetEncoding("gb2312").GetBytes(new Char[] { chr }); int n = (int)gb2312_bt[0] << 8; n += (int)gb2312_bt[1]; textBox2.Text = n.ToString(); } catch(Exception) { MessageBox.Show("请输入汉字字符!","出现错误!"); }
获取汉字编码值