Linux and security practices five--Character set encoding
One, ASCII code
The hexadecimal value corresponding to the English letter lxq is found in the table:
4c 58 51
Enter the command in the terminal: Vim Test1.txt
Enter the command on the VIM page:%! Xxd
Use command after losing:%! The following results can be seen when Xxd-r is saved:
Exit the vim Editor and enter the command in the terminal:cat test.txt can view content in test.txt
Second, gb2312 code
Find the hexadecimal value corresponding to the Li Sheli in the encoding table:
C0ee d1a9 e7f9
In the vim editing, the terminal encoding method is modified to gb2312, in the terminal options above the end of the modification,:
After modification, use the command locale -a|grep zh_cn to view the currently owned Chinese character set:
Next, change the character set to the default character set, using the cross-platform 16-HexEdit editor.
Enter the command in the terminal:hexedit text2.txt
As you can see, the interface is friendly, but it's edited in bytes. Enter content into which
Ctrl+w Save, Ctrl+x exit
Change the character set to gb2312 again, and use the Cat directive to view the content
Iii.Utf-8
Find the hexadecimal value corresponding to the Li Sheli in the encoding table:
e69d8e E99baa E790a6
Because the virtual machine default character set is Utf-8, we can see the results in the terminal interface without any setup.
Enter the command in the terminal: Vim Text3.txt
Enter the command on the VIM page:%! Xxd
Use command after losing:%! The following results can be seen when Xxd-r is saved:
Exit the vim Editor and enter the command in the terminal:cat test3.txt can view content in text3.txt
Linux and security practices five--Character set encoding