Home  >  Article  >  Operation and Maintenance  >  Solution to garbled characters in Linux terminal

Solution to garbled characters in Linux terminal

尚
Original
2019-12-25 11:11:582756browse

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn