The concept of Chinese encoding, character set, GBK, UTF-8

Source: Internet
Author: User

What does a character set refer to?

The character set is a man-made rule, and people use a booklet to specify the correspondence between "literal characters" and "numbers".

where each character corresponds to an array is also called the encoding.

For example, the ASCII code table is a character set

Char ' A ' = 65,a is encoded as 65

Char ' 0 ' = 48,0 is encoded as 48

Character sets are developed and published by some organizations, such as ISO/IEC, which are responsible for developing character sets.

Each character set has a standard number, such as the ASCII character set number is ISO/IEC 646.

"Latin Character Set (Latin)"

Latin Character Set: Contains the characters of various European countries. For example, the Greek alphabet, αα,ββ

The Latin character set is numbered in the ISO 8859 series

For example: The iso8859-1 character set, also known as Latin-1, is the characters commonly used of Western Europe, including the letters of Germany and France.

The iso8859-2 character set, also known as Latin-2, collects Eastern European characters.

Note: The total number of Latin characters exceeds 256 and cannot be represented by a char type, which requires 2 bytes.

So even if you don't use Chinese, there are problems with the representation of foreign letters.

Char a= ' alpha ';//problematic

Problem reason: One character cannot be represented in one byte.

Char str[]= "αβ";//Five bytes of storage->sizeof (str)

"Chinese Character Set"

GB2312 Chinese GB Code (number of Chinese characters: 6763)

GBK Extended Chinese GB encoding (compatible with GB2312)

GB18030 1-4-byte encoding for extra-large capacity

BIG5 Chinese Traditional Code

CJK Chinese-Japanese-Korean large character set encoding

Unicode Unified code, using 0-0X10FFFF to map the language of countries around the world.

"GB2312/GBK"

Double-byte encoding with a high position of 1 per byte

Does not contain uncommon characters

For the names of people, ancient Chinese and other aspects of rare words, GB2312 can not be processed, which led to the subsequent GBK and GB 18030 character set appearance

GBK compatible with GB2312, more commonly used.

"Unicode"

A character encoding scheme developed by international organizations that can accommodate all the words and symbols in the world.

0-0X10FFFF (maximum of 1,114,112 characters)

"Problem" Unicode uses a few bytes to represent a character?

First Scenario: UFT-32 encoding

Each character is represented by an int

Features: simple, but too wasted space

Second Scenario: UTF-16 encoding

Feature: Use 1-2 short to represent a character

Third Scenario: UTF-8 encoding

1-4 bytes to represent one character (more space saving)

The concept of Chinese encoding, character set, GBK, UTF-8

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.