Python string and encoding

Source: Internet
Author: User

ASCII encoding:

The computer was invented by the Americans, so the string has only numbers, English letters and special characters, a total of 127 characters are encoded in the computer, this encoding table is called ASCII encoding. This encoding stores characters using only one byte, or 8bit.

Unicode (Universal code, unified Encoding):

But to store the world's characters 1byte is definitely not enough. At this time the Unicode encoding came into being, most commonly used to represent a character in 2byte.

UTF-8 Code:

Using Unicode solves the problem of garbled characters, but if the text is in English, the storage is too wasteful and bandwidth is wasted while it is being transmitted. So in order to solve this problem, UTF-8 coding came into being. The way to do this is to convert the Unicode encoding into UTF-8 encoding. English occupies 1byte, Chinese characters occupy 3byte, very uncommon words only use 4-6byte. The ASCII code can actually be seen as part of the UTF-8.

Python string and encoding

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.