获取汉字的GBK码

private void button_Inquriy_Click(object sender, EventArgs e)
	        {
	            if (textBox_Inquiry.TextLength > 0)
	            {
	                String strInquiry = textBox_Inquiry.Text;
	                byte[] bytes = Encoding.GetEncoding("GB2312").GetBytes(strInquiry);
	                String strResult = String.Empty;
	                foreach (byte b in bytes)
	                {
	                    strResult += b.ToString("X2");
	                    strResult += " ";
	                }
	                textBox_Result.Text = strResult;
	            }
	            else
	            {
	                MessageBox.Show("请输入待查询的字符");
	            }
	        }


版权声明:本文为Joyhen原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。