Analysis of Chinese garbled problem in web development

Source: Internet
Author: User

In the work often appears the Chinese character character garbled problem, as well as ASCII, Iso-8859-1, gb2312, GBK, Unicode, Utf-8, utf-16 ... What exactly does the code mean, and why encode it?

because the computer can be recognized only 0, 1, so the various characters into the 01 format, the encoding is a character and the number of a corresponding relationship. acsii Code:Computer first appeared in the United States, 26 letter case, number, carriage return line and other symbols, with a byte can be done, and only a byte of the first seven bits, that is128 Characters, the highest bit constant is 0. iso-8859-1:With the popularization of computers, the different languages of each country put forward new requirements for character encoding, the original 128 characters are not enough, people will be the highest ASCII code of a use up,expanded into 256 characters, there is the Iso-8859-1 encoding method, it is compatible with ASCII code. GBK:When the computer came to China, the problem came again, 256 characters are not enough, China's commonly used Chinese characters have more than 6,000, plus some less commonly used there are more than 20,000, people by adding bytes of the way to encode Chinese characters,that is, expanding from one byte to two bytes, this is the gb2312 code, and later on gb2312 expanded to form a GBK encoding, which is compatible with gb2312. Unicode:So each country has a set of its own coding scheme,incompatible with each other and unable to communicate。 Therefore, the International Organization for Standardization of a unified global Unicode encoding scheme, it has multiple versions, currently commonly used is a two-byte encoding scheme. UTF-8, UTF-16:Now that Unicode has solved the problem of internationalization of coding, what do we often hear about utf-8, utf-16, and what are they used to solve problems? Encoding is just a correspondence between characters and numbers, and Unicode code is a correspondence of this kind.but it doesn't have to do with storage and transport issues.。 Which byte is stored before which byte is behind? Which byte is transmitted first in the network transmission? How does the computer determine whether two bytes are two ASCII or a Unicode code when reading a file? Therefore, a unified storage and transport format is required to represent Unicode codes, a unified implementation known as UTF (Unicode Transformation format). UTF-16 and Unicode code exactly, but if an English article with UTF-16 to store, the space caused a lot of waste;so UTF-8 was born, it is a variable length encoding method, according to different Unicode code with different byte length, reduce the waste of resources. garbled problem:1, the root operating system, file saving type 2, different items using different encoding format 3, in the Head Declaration encoding type, save with another encoding format 4, the network transmission garbled, the client and the service side of the request and received the encoding format inconsistent All the garbled problem is the encoding and decoding format inconsistency caused, but because one operation often involves multiple codecs, so garbled sometimes difficult to find out which part of the problem, so it is necessary to debug with the code.

Analysis of Chinese garbled problem in web development

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.