Home  >  Article  >  What are the differences between unicode and ascii

What are the differences between unicode and ascii

百草
百草Original
2023-09-06 11:56:065717browse

The differences between unicode and ascii include different encoding ranges, different storage spaces, and different compatibility. Detailed introduction: 1. The encoding range is different. The encoding range of ASCII is 0-127, which is mainly used to represent English letters. The encoding range of Unicode is much wider and can represent almost all language characters; 2. The storage space is different. ASCII usually Use 1 byte to store a character, while unicode may use 2 or more bytes to store a character; 3. Different compatibility, etc.

What are the differences between unicode and ascii

The operating system for this tutorial: Windows 10 system, DELL G3 computer.

1. What is Unicode

Unicode is a character encoding standard. Its goal is to set a small number of codes for every character in the world. It can accommodate characters of almost all languages ​​including English letters, Chinese characters, Japanese characters, Korean characters, Arabic numerals, etc.

2. What is ASCII

ASCII (American Standard Code for Information Interchange, American Standard Code for Information Interchange) is a character encoding based on English characters. It uses 7 bits to represent a character, and can represent a total of 128 different characters, including uppercase and lowercase English letters, Arabic numerals, punctuation marks, and some control characters.

3. The difference between Unicode and ASCII

The difference between unicode and ascii is mainly reflected in: 1. Different encoding ranges; 2. Storage space Different; 3. Different compatibility. In general, Unicode contains more characters than ASCII and can represent more languages.

1. Different coding ranges

The coding range of ASCII is 0-127, which is mainly used to represent English letters; while the coding range of Unicode is much wider and can represent almost all language characters.

2. Different storage spaces

ASCII encoding usually uses 1 byte to store a character, while Unicode encoding may use 2 or more bytes to store a character.

3. Different compatibility

ASCII encoding is part of Unicode encoding, that is to say, all ASCII characters have corresponding encodings in Unicode encoding. This also means that ASCII-encoded text can be converted directly to Unicode encoding without losing any information.

4. UTF8

  • So, in the spirit of conservation, UTF-8 encoding that converts Unicode encoding into "variable length encoding" appeared.
  • UTF-8 encoding encodes a Unicode character into 1-6 bytes according to different number sizes. Commonly used English letters are encoded into 1 byte. Chinese characters are usually 3 bytes, and only a few Uncommon characters will be encoded into 4-6 bytes. If the text you want to transmit contains a lot of English characters, using UTF-8 encoding can save space.
Characters ASCII Unicode UTF-8
A 01000001 00000000 01000001 01000001
中文 x 01001110 00101101 01001110 00101101
    ## From the above table, we can also find that UTF-8 encoding has an additional The advantage is that ASCII encoding can actually be regarded as part of UTF-8 encoding. Therefore, a large number of historical legacy software that only supports ASCII encoding can continue to work under UTF-8 encoding.

5. How common character encoding works in computers

    In the computer memory, Unicode encoding is used uniformly, and when it needs to be saved to the hard disk Or when it needs to be transmitted, convert it to UTF-8 encoding.
  • When editing with Notepad, the UTF-8 characters read from the file are converted into Unicode characters and stored in the memory. After the editing is completed, Unicode is converted into UTF-8 when saving. To the file:

  • What are the differences between unicode and ascii

  • When browsing the web, the server will convert the dynamically generated Unicode content into UTF-8 and then transmit it. To the browser:

  • What are the differences between unicode and ascii

The above is the detailed content of What are the differences between unicode and ascii. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn