c Chinese gbk encoder query sample code

  • 2020-05-27 06:59:07
  • OfStack


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(" Please enter the character to be queried ");
     }
 }


Related articles: