The understanding of Unicode encoding from Ord ()

Source: Internet
Author: User

When I started to learn programming, the old understanding of string encoding was vague. have been looking at this handy information, today when looking at dive in Python, suddenly have a new understanding (do not know whether it is correct).

Python has a built-in function, Ord (), which returns the Unicode value of a character. This function has no other arguments, that is, given a character, there will be a specific value corresponding to it. is not related to the specific code (UTF-8,UTF-16,GB2312).

My previous mistake was that each set of encodings had its own corresponding table.

It now appears that the Unicode standard encompasses all the characters in the world, each with a corresponding Unicode value.

My so-called coding, such as UTF8, UTF16, gb2312, etc., is only serialized into binary mode when it is saved to disk or transmitted over the network, and it has nothing to do with the Unicode value of the character.

Utf-32 saves a character with 4 bytes, although it is a waste of space, but from binary parsing (decode) into characters, the speed is certainly faster than UTF8, because every four bytes represents a character, and the character that finds a specific position in a stream must be fast, O (1).

Utf-8 saves space, but finding specific location characters is difficult and time efficiency is O (n)

The understanding of Unicode encoding from Ord ()

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.