Home >Operation and Maintenance >Linux Operation and Maintenance >Solution to garbled characters in Linux terminal
Terminal tools generally use the default utf-8 encoding format. If the terminal setting utf-8 is still garbled, the problem is that there is a problem with the Linux encoding format.
Set Linux encoding format
Add the following code in .vimrc (create a new one if there is no .vimrc)
vim ~/.vimrc
set encoding=utf-8 fileencodings=ucs-bom,utf-8,cp936
(1) Execute the locale command to view the system language
# locale LANG=C LC_CTYPE="zh_CN.UTF-8" LC_NUMERIC="zh_CN.UTF-8" LC_TIME="zh_CN.UTF-8" LC_COLLATE="zh_CN.UTF-8" LC_MONETARY="zh_CN.UTF-8" LC_MESSAGES="zh_CN.UTF-8" LC_PAPER="zh_CN.UTF-8" LC_NAME="zh_CN.UTF-8" LC_ADDRESS="zh_CN.UTF-8" LC_TELEPHONE="zh_CN.UTF-8" LC_MEASUREMENT="zh_CN.UTF-8" LC_IDENTIFICATION="zh_CN.UTF-8" LC_ALL=
(2) Set the system environment variable LANG to en_US.UTF-8:
export.UTF-8
Or edit the file: vim /etc/sysconfig/i18n
Recommended related article tutorials: linuxtutorial
The above is the detailed content of Solution to garbled characters in Linux terminal. For more information, please follow other related articles on the PHP Chinese website!