Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Example Analysis of cat Chinese garbled Code / vim non-garbled Code or cat non-garbled Code / vim Chinese garbled Code under linux system Terminal

2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article will explain in detail about linux system terminal cat Chinese garbled/vim not garbled or cat not garbled/vim Chinese garbled example analysis, the quality of the article content is high, so Xiaobian share for everyone to make a reference, I hope you have a certain understanding of related knowledge after reading this article.

Scenario: in linux system terminal, use cat to view Chinese document garbled, and use vim to view the same file without garbled. (secureCRT window code utf-8)

Use cat to view Chinese documents without garbled, the same file using vim to view garbled. (secureCRT window code is gb2312)

Analysis: The two cases are garbled separately, so it is determined that cat and vim use different decoding methods, resulting in this situation.

Workaround: change vim parse file encoding.

In vimrc, you can set encoding, fileencoding and fileencodings.

encoding: vim internal encoding method, consistent with locale by default

fileencoding: encoding method used when creating new text

fileencodings: the encoding method used when opening text, there can be multiple, decoding one by one

Changed settings:

set fileencodings=utf-8,gbk,gb2312,gb18030

set fileencoding=utf-8

set encoding=gbk

gb18030 for secureCRT windows

linux system code/etc/sysconfig/i18n LANG="zh_CN.GB18030"

If an error occurs while executing the print script, add it in the first line

#coding:utf-8

On linux system terminal cat Chinese garbled/vim not garbled or cat not garbled/vim Chinese garbled sample analysis shared here, I hope the above content can be of some help to everyone, you can learn more knowledge. If you think the article is good, you can share it so that more people can see it.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report