In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article will explain in detail the differences between unicode and ascii. The editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.
Difference: 1. ASCII encoding is 1 byte, while Unicode encoding is usually 2 bytes. 2. ASCII is a single-byte code and cannot be used to represent Chinese, while Unicode can represent all languages. 3. Unicode coding requires twice as much storage space as ASCII coding.
The operating environment of this tutorial: windows7 system, Dell G3 computer.
ASCII coding
ASCII codes use a specified combination of 7-bit or 8-bit binary numbers to represent 128 or 256 possible characters. Standard ASCII codes, also known as base ASCII codes, use 7-digit binary numbers (the remaining 1-bit binary is 0) to represent all uppercase and lowercase letters, the numbers 0 to 9, punctuation, and special control characters used in American English. The last of them is used for parity.
Problem: ASCII is a single-byte code and cannot be used to represent Chinese (Chinese coding requires at least 2 bytes), so China has developed a GB2312 code to code Chinese into it. But there are many different languages in the world, so a unified coding is needed.
Unicode
Unicode unifies all languages into one set of codes so that there are no more garbled problems.
Unicode is most commonly used to represent a character in two bytes (4 bytes if very remote characters are to be used). Unicode is directly supported by modern operating systems and most programming languages.
The difference between Unicode and ASCII
The ASCII encoding is 1 byte, while the Unicode encoding is usually 2 bytes.
The letter An is decimal 65 in ASCII and 01000001 in binary; in Unicode, it only needs to be preceded by 0, that is, 00000000 01000001.
New problem: if it is unified into Unicode coding, the garbled problem will disappear. However, if you write almost all the text in English, coding in Unicode requires twice as much storage space as ASCII coding, and it is not cost-effective in storage and transmission.
UTF8
Therefore, in the spirit of economy, there is a UTF-8 code that transforms Unicode coding into "variable length coding".
UTF-8 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 very obscure characters are encoded into 4-6 bytes. If the text you want to transfer contains a large number of English characters, you can save space by encoding in UTF-8.
Character ASCIIUnicodeUTF-8A0100000100000000 0100000101000001 Chinese x0100111000101010100111000101101
You can also find from the table above that UTF-8 coding has an additional benefit that ASCII coding can actually be seen as part of UTF-8 coding, so a large number of historical legacy software that only supports ASCII coding can continue to work under UTF-8 coding.
The way character coding works commonly used in computers
Unicode coding is used uniformly in computer memory, and when it needs to be saved to the hard disk or transferred, it is converted to UTF-8 coding.
When editing with notepad, the UTF-8 characters read from the file are converted to Unicode characters into memory, and after editing, the Unicode is converted to UTF-8 and saved to the file:
When browsing the web, the server converts the dynamically generated Unicode content into UTF-8 and then transmits it to the browser:
This is the end of the article on "what's the difference between unicode and ascii". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
File name: checkbox.htmlCheckbox Checkbox < / h4 >
© 2024 shulou.com SLNews company. All rights reserved.