Conversion between fullwidth and halfwidth (implemented in C)

Source: Internet
Author: User

Currently, we are mainly engaged in Chinese character encoding including GBK and GB2312. GB2312, also known as the country code, is a simplified character encoding specification. It also contains other symbols, letters, and Japanese Kana. It contains a total of 7445 graphic characters, of which 6763 are Chinese characters. We usually say 6768 Chinese characters. In fact, there are 5 blank codes, so there are a total of 6763 Chinese characters. GB2312 stipulates that "two bytes are used for any graphic character, and each byte is represented by a seven-bit encoding". The first byte is typically referred to as a "high byte ", the second byte is "low Byte ". The encoding range of Chinese Characters in GB2312 is: the first byte 0xB0-0xF7 (corresponding to decimal: 176-247), and the second byte 0xA0-0xFE (corresponding to decimal: 160-254 ). GBK is an extension of GB2312 and is compatible with the above. The Chinese character encoding in GB2312 is the same as that in GBK, but GBK also contains the traditional Chinese character encoding. Each Chinese Character in GBK still occupies two bytes. The first byte range is 0x81-0xFE (that is, 129-254), and the second byte range is 0x40-0xFE (that is, 64-254 ). GBK contains 23940 bitwise characters and 21003 Chinese characters. Therefore, the following code is also passed in the GB2312 or GBK encoding environment.

   sbc_to_dbc( *sbc,  *      (; *sbc; ++          ((*sbc & ) ==  && (*(sbc + ) & ) == )                      *dbc++ =              ++           ((*sbc & ) ==  && (*(sbc + ) & ) >=  && (*(sbc + ) & ) <= )                 *dbc++ = *++sbc -                        (*sbc < )                     *dbc++ = *sbc++             *dbc++ = *       *dbc =      dbc_to_sbc( *dbc,  *      (; *dbc; ++          ((*dbc & ) == )                  *sbc++ =              *sbc++ =            ((*dbc & ) >=  && (*dbc & ) <=               *sbc++ =              *sbc++ = *dbc +                         (*dbc < )                     *sbc++ = *dbc++             *sbc++ = *       *sbc =  }

 

Related 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.