mirror of
https://github.com/krahets/hello-algo.git
synced 2026-07-07 11:36:46 +08:00
deploy
This commit is contained in:
@@ -4437,9 +4437,8 @@
|
||||
<h2 id="343-unicode-character-set">3.4.3 Unicode Character Set<a class="headerlink" href="#343-unicode-character-set" title="Permanent link">¶</a></h2>
|
||||
<p>With the vigorous development of computer technology, character sets and encoding standards flourished, which brought many problems. On the one hand, these character sets generally only define characters for specific languages and cannot work normally in multilingual environments. On the other hand, multiple character set standards exist for the same language, and if two computers use different encoding standards, garbled characters will appear during information transmission.</p>
|
||||
<p>Researchers of that era thought: <strong>If a sufficiently complete character set were released to include all languages and symbols in the world, wouldn't that solve problems in cross-language environments and eliminate garbled text</strong>? Driven by this idea, a large and comprehensive character set, Unicode, was born.</p>
|
||||
<p><u>Unicode</u>, or Unified Code, can theoretically accommodate over one million characters. It is committed to including characters from around the world into a unified character set, providing a universal character set to handle and display various language texts, reducing garbled character problems caused by different encoding standards.</p>
|
||||
<p>Since its release in 1991, Unicode has continuously expanded to include new languages and characters. As of September 2022, Unicode has included 149,186 characters, including characters, symbols, and even emojis from various languages. In practical storage and encoding schemes for this vast character set, commonly used characters often occupy 2 bytes, while some rare characters occupy 3 bytes or even 4 bytes.</p>
|
||||
<p>Unicode is a universal character set that essentially assigns a number (called a "code point") to each character, <strong>but it does not specify how to store these character code points in computers</strong>. We can't help but ask: when Unicode code points of multiple lengths appear simultaneously in a text, how does the system parse the characters? For example, given an encoding with a length of 2 bytes, how does the system determine whether it is one 2-byte character or two 1-byte characters?</p>
|
||||
<p><u>Unicode</u>, or Unified Code, can theoretically accommodate over one million characters. It is committed to including characters from around the world into a unified character set, providing a universal character set to handle and display various language texts, reducing garbled character problems caused by different encoding standards. Since its release in 1991, Unicode has continuously expanded to include new languages and characters. As of September 2022, Unicode has included 149,186 characters, including characters, symbols, and even emojis from various languages.</p>
|
||||
<p>As a universal character set, Unicode essentially assigns each character a unique "code point" (character identifier), whose range is U+0000 to U+10FFFF, forming a unified character numbering space. However, <strong>Unicode does not specify how to store these character code points in computers</strong>. We can't help but ask: when Unicode code points of multiple lengths appear simultaneously in a text, how does the system parse the characters? For example, given an encoding with a length of 2 bytes, how does the system determine whether it is one 2-byte character or two 1-byte characters?</p>
|
||||
<p>For the above problem, <strong>a straightforward solution is to store all characters as equal-length encodings</strong>. As shown in Figure 3-7, each character in "Hello" occupies 1 byte, and each character in "算法" (algorithm) occupies 2 bytes. We can encode all characters in "Hello 算法" as 2 bytes in length by padding the high bits with 0. In this way, the system can parse one character every 2 bytes and restore the content of this phrase.</p>
|
||||
<p><img alt="Unicode encoding example" class="animation-figure" src="../character_encoding.assets/unicode_hello_algo.png" /></p>
|
||||
<p align="center"> Figure 3-7 Unicode encoding example </p>
|
||||
|
||||
Reference in New Issue
Block a user