Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to make unicode to gb2312 Mapping Table in C #

Shulou Source: shulou.com Published: 2022-06-02 05:18:53 10月06日 Update

This article mainly introduces "how to make unicode to gb2312 mapping table in C#". In daily operation, I believe many people have doubts about how to make unicode to gb2312 mapping table in C#. The editor consulted all kinds of data and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts of "how to make unicode to gb2312 mapping table in C#". Next, please follow the editor to study!

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 WindowsFormsApplication1 {public partial class Form1: Form {public Form1 () {InitializeComponent ();} class unit_converter: IComparable {public int gb2312 = 0; public int unicode = 0 Public unit_converter () {} public unit_converter (int gb2312_0, int gb2312_1) {init_with_gb2312 (gb2312_0, gb2312_1);} private int CompareWithUnicode (unit_converter other) {return unicode.CompareTo (other.unicode) } private int CompareWithGB2312 (unit_converter other) {return gb2312.CompareTo (other.gb2312) } public int CompareTo (unit_converter other) {if (unicode = = other.unicode) {Console.WriteLine ("something wrong with gb2312:" + gb2312.ToString ("X4") + "unicode:" + unicode.ToString ("X4"));} return CompareWithUnicode (other) / / return CompareWithGB2312 (other);} private byte [] _ gb2312 = new byte [2]; private byte [] _ unicode = new byte [2]; public void init_with_gb2312 (int gb2312_0, int gb2312_1) {_ gb2312 [0] = (byte) gb2312_0 _ gb2312 [1] = (byte) gb2312_1; gb2312 = _ gb2312 [0] * 256 + _ gb2312 [1]; String s_target_gb2312 = System.Text.Encoding.GetEncoding ("GB2312"). GetString (_ gb2312); byte [] b_target_unicode = System.Text.Encoding.GetEncoding ("unicode"). GetBytes (s_target_gb2312) _ unicode [0] = b_target_unicode [1]; _ unicode [1] = b_target_unicode [0]; unicode = _ unicode [0] * 256 + _ unicode [1];} private void init_with_unicode (int unicode_0, int unicode_1) {_ unicode [0] = (byte) unicode_1 _ unicode [1] = (byte) unicode_0; unicode = _ unicode [0] * 256 + _ unicode [1]; String s_target_unicode = System.Text.Encoding.GetEncoding ("unicode"). GetString (_ unicode); byte [] b_target_gb2312 = System.Text.Encoding.GetEncoding ("GB2312"). GetBytes (s_target_unicode) _ gb2312 [0] = b_target_gb2312 [0]; _ gb2312 [1] = b_target_gb2312 [1]; gb2312 = _ gb2312 [0] * 256 + _ gb2312 [1];}} List elements = new List (); private void make_src_gb2312 () {for (int index_level_1 = 0xA1) Index_level_1 < 0xAA; index_level_1++) {for (int index_level_2 = 0xA1; index_level_2 < 0xFF; index_level_2++) {elements.Add (new unit_converter (index_level_1, index_level_2));}} for (int index_level_1 = 0xB0) Index_level_1 < 0xF7; index_level_1++) {for (int index_level_2 = 0xA1; index_level_2)

Tags: Caching production learning more help practical next articles methods theories knowledge articles websites materials follow questions good use practice solutions Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia macOS Shulou Information Linux MariaDB