Home >Operation and Maintenance >CentOS >How to solve centos cat garbled problem

How to solve centos cat garbled problem

藏色散人
藏色散人Original
2022-01-27 15:15:284316browse

Centos cat garbled solution: 1. Set the encoding format to utf-8 through ":set encoding=utf-8"; 2. Load the file with cp936 encoding as ":edit enc=cp936" .

How to solve centos cat garbled problem

The operating environment of this article: CentOS 7 system, vim v8.2.4141 version, DELL G3 computer

How to solve the problem of centos cat garbled characters ?

CENTOS cat command Chinese garbled VIM garbled code

cat test.txt | iconv -f GBK -t UTF-8

Temporarily transcode, OK

VIM:

First method: Set the encoding format to utf-8 (I did not succeed)

# 命令行模式
:set encoding=utf-8

Second method: Load the file in cp936 encoding: edit enc=cp936, which can be abbreviated as: e enc =cp936 (Success)

# 命令行模式
:e ++enc=cp936

If most of the files you see are garbled, you must change the VIM configuration file to avoid the trouble of setting them up one by one.

Find the vim configuration file/etc/vimrc

Add the following code

set fileencodings=utf-8,gb2312,gbk,gb18030
set termencoding=utf-8
set fileformats=unix
set encoding=prc

Recommended: "centos usage tutorial"

The above is the detailed content of How to solve centos cat garbled problem. 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