Write the Code. Change the World.

8月 25

vim /> 新买的云,状的是centos8系统,使用起来发现文件内中文乱码。这个得解决。

一步一步往下走

查看你的语言是什么

echo $LANG

# 结果
zh_CN.UTF-8

**继续 **

localectl status

# 结果
   System Locale: LANG=en_US.UTF-8
       VC Keymap: us
      X11 Layout: us

发现系统缺少中文包。弄起来。

yum search Chinese

# 结果
Failed to set locale, defaulting to C.UTF-8
Last metadata expiration check: 3:04:20 ago on Thu Aug 25 10:58:01 2022.
========================================== Name & Summary Matched: chinese ===========================================
ibus-table-chinese.noarch : Chinese input tables for IBus
=============================================== Name Matched: chinese ================================================
ibus-table-chinese-array.noarch : Array input methods
ibus-table-chinese-cangjie.noarch : Cangjie based input methods
ibus-table-chinese-cantonese.noarch : Cantonese input methods
ibus-table-chinese-easy.noarch : Easy input method
ibus-table-chinese-erbi.noarch : Erbi input method
ibus-table-chinese-quick.noarch : Quick-to-learn input methods
ibus-table-chinese-scj.noarch : Smart Cangjie
ibus-table-chinese-stroke5.noarch : Stroke 5 input method
ibus-table-chinese-wu.noarch : Wu pronunciation input method
ibus-table-chinese-wubi-haifeng.noarch : Haifeng Wubi input method
ibus-table-chinese-wubi-jidian.noarch : Jidian Wubi 86 input method, JiShuang 6.0
ibus-table-chinese-yong.noarch : YongMa input method
============================================== Summary Matched: chinese ==============================================
autocorr-zh.noarch : Chinese auto-correction rules
langpacks-zh_CN.noarch : Simplified Chinese langpacks meta-package
langpacks-zh_TW.noarch : Traditional Chinese langpacks meta-package
texlive-arphic.noarch : Arphic (Chinese) font packages
wqy-microhei-fonts.noarch : Compact Chinese fonts derived from Droid

那么,就装个中文包。

dnf install langpacks-zh_CN.noarch

修改本地语言环境。

vim /etc/locale.conf

# 填入
LANG=zh_CN.UTF-8

# 使生效
source /etc/locale.conf