The Chinese character encoding is also represented by a number like an English character, but we can directly insert an ASCII table into the corresponding English character. How do we know the encoding of a Chinese character ???
Simply put, the Chinese character storage occupies two bytes, and the first byte corresponds to the number shifted to eight places, plus the number corresponding to the second byte, is the final Chinese character encoding. Use C # To make the interface as follows:
CorrespondingCodeThe principle is as follows: read any book. The results are displayed in textbox and ListBox.
Using system; using system. collections. generic; using system. componentmodel; using system. data; using system. drawing; using system. LINQ; using system. text; using system. threading. tasks; using system. windows. forms; namespace get Chinese character code {public partial class form1: FORM {public form1 () {initializecomponent ();} private void btnsure_click (Object sender, eventargs e) {int K = 0; txtoutput. TEXT = ""; int I = txtinput. text. length; while (k <I) {char c = txtinput. text [k]; byte [] gb2312_bt = encoding. getencoding ("gb2312 "). getbytes (New char [] {c}); int n = (INT) gb2312_bt [0] <8; n + = (INT) gb2312_bt [1]; txtoutput. TEXT = n. tostring () + "\ r \ n" + txtoutput. text; listbox1.items. add (txtinput. text [k] + ":" + N. tostring (); ++ K;} private void txtoutput_textchanged (Object sender, eventargs e ){}}}
The effect is as follows: