How to solve centos cat garbled problem

藏色散人
Release: 2022-01-27 15:15:28
Original
4279 people have browsed it

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
Copy after login

Temporarily transcode, OK

VIM:

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

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

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

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

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
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template