Obtain the Chinese character internal code in the VC text editing box

Source: Internet
Author: User

In the past few days, I have helped a senior student build a graduation project. To implement a 5110 embedded Chinese font library, I need to write a VC window. Simply put, I need to enter a Chinese character and get its internal code, chinese character encoding is involved.

Let's talk about the Chinese character internal code, the Chinese character internal code, also known as "Chinese Character ASCII code", referred to as "Internal code", refers to the internal storage of the computer, the code used to process and transmit Chinese characters consists of 0 and 1 Symbols. After the input code is accepted, the "input code conversion module" of the Chinese character operation system is converted to the inner code, which is irrelevant to the keyboard input method used. The inner code is the most basic encoding of Chinese characters. No matter what Chinese character system or Chinese Character Input Method, the inner code of the entered Chinese characters must be converted into the inner code, to be stored and processed.

Chinese characters are unique in the computer. Because the Chinese character processing system must ensure the compatibility of Chinese and Western characters, when both the ASCII code and the Chinese character National Standard Code exist in the system, it will produce ambiguity. For example, there are two bytes of content: 30 h and 21 H. It can both represent the Chinese character "ah", and the Chinese character "0" and "!". . To this end, the Chinese character machine internal code should be properly processed and transformed.

The internal code of the GB code is a two-byte code that adds "1" to the highest bit of each byte of the corresponding GB code, that is, the internal code of the Chinese character machine = the Chinese character code + 8080 H. For example, the above-mentioned "ah" Chinese character code is 3021 h, and the Chinese character machine internal code is b0a1h.

The principle is over. How can this VC program be implemented?

It is easy to retrieve the area code and bit Code separately. You can change the location.

 

void Main_OnCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify)  {      switch(id)      {          case IDC_OK:                        TCHAR ps[256];          TCHAR name2[256];          unsigned short int tmp;          TCHAR t;          GetDlgItemText(hwnd, IDC_EDIT1, ps, sizeof(ps));              t=*ps;          *ps=*(ps+1);          *(ps+1)=t;          tmp=*(short int*)ps;          itoa(tmp,name2,16);          //wsprintf(name2, "%d", tmp);          SetDlgItemText(hwnd, IDC_EDIT2, name2);                        break;          default:          break;      }  }  

Bytes ------------------------------------------------------------------------------------------------------------------

Author: PANG Hui

Source: http://www.cnblogs.com/pang123hui/

This article is based on the signature 2.5 mainland China license agreement. You are welcome to repost, interpret, or use it for commercial purposes. However, you must keep the signature Pang Hui (including the link) of this Article ).

 


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.