c#中文gbk编码查询示例代码

前端技术 2023/09/03 C#

复制代码 代码如下:

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(\"请输入待查询的字符\");
     }
 }

本文地址:https://www.stayed.cn/item/6135

转载请注明出处。

本站部分内容来源于网络,如侵犯到您的权益,请 联系我

我的博客

人生若只如初见,何事秋风悲画扇。