Vscode is a cross-platform IDE that supports multiple languages and has very plug-ins. It is very convenient to use it to view source code and view the hex or UTF-8 encoding of files. Here it is recommended to view the hex or UTF-8 plug-in in vscode: Hex Editor, as follows.
1 Install Hex Editor
Open vscode, click the field icon on the left -- "In the "Extension Store", enter hex, select Hex Editor —> install.
2 View UTF-8 encoding
Drag the file to be viewed into vscode, for example, drag hello.txt into vscode --> right-click hello.txt in the tab page of vscode --> reopen the editor --> Hex Editor --" to get the file bag UTF-8 encoding, as shown in Figure (2) and Figure (3):
Click on the first byte, the details are displayed on the right, and the UTF8 encoding of the Chinese word "天" is obtained: E5 A4 A9, as shown in Figure (4):
3 UTF-8 encoding of the word "cloud" in different contexts
Li Bai's poem: "Looking up at the bright moon, bowing your head and thinking about your hometown", is also the moon, which is called "Moon" in Chinese and "Moon" in English. It is also a cloud in the sky, with different languages and different representation methods, so its UTF-8 is also different.
language | original | UTF-8 encoding |
---|---|---|
English | cloud | 0x63 6C 6F 7F 64 |
Chinese | cloud | 0xE4 BA 91 |
Russian | clouds | 0xD0 BE D0 B1 D0 BB D0 B0 D0 BA D0 B0 |
Korean | cloud | 0xEA B5 AC EB A6 84 |
Japanese | Cloud | 0xE3 82 AF E3 83 A9 E3 82 A6 E3 83 89 |
French | Cloud | 0x4E 75 61 67 65 |
German | Clouds | 0x57 6F 6C 6B 65 |
spanish | Cloud | 0x4E 75 62 65 |
vietnamese | Cloud | 0x4D C3 A2 79 |
Congo | open | 0x6D 62 75 6B 61 |
Persian | Cloud | 0xD8 A7 D8 A8 D8 81 |
Finnish | cloud | 0x70 69 6C 76 69 |