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

Solve the problem of CentOS8 occurrence-bash: garbled

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

Share

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

This article mainly explains how to solve the CentOS8-bash: garbled code problem, the content is clear and clear, interested friends can learn about it, I believe everyone will be helpful after reading it.

This is usually due to the absence of a Chinese language pack or a problem with the default language settings.

View current locale

echo $LANG

found to be

zh_TW.UTF-8

But Chinese language pack is not installed or not enabled, there will be garbled

Enter LANG=en_US to set the display to English. This command takes effect immediately, but it cannot take effect permanently. See below for permanent effect.

At this point, enter the command again and you can see the English error message.

If you must have a Chinese prompt, you can install it like this:

yum groupinstall chinese-support

Set local default locale

vim /etc/locale.conf Join

LANG="zh_TW.UTF-8"

immediate and permanent effect

source /etc/locale.conf

Enter locale to view the local locale

LANG=zh_TW.UTF-8LC_CTYPE="zh_TW.UTF-8"LC_NUMERIC=zh_TW.UTF-8LC_TIME=zh_TW.UTF-8LC_COLLATE="zh_TW.UTF-8"LC_MONETARY=zh_TW.UTF-8LC_MESSAGES="zh_TW.UTF-8"LC_PAPER=zh_TW.UTF-8LC_NAME="zh_TW.UTF-8"LC_ADDRESS="zh_TW.UTF-8"LC_TELEPHONE="zh_TW.UTF-8"LC_MEASUREMENT=zh_TW.UTF-8LC_IDENTIFICATION="zh_TW.UTF-8"LC_ALL=

Note that my change language environment is Taiwan Traditional, Chinese Simplified should be changed to CN

Appendix: See below centos showing utf-8 encoding format shell script has Chinese garbled code solution

problem phenomenon

Shell script written by myself, save the encoding format utf-8, but upload to centos, show as garbled

Use file shell.sh to view the encoding format of the file

shell.sh: UTF-8 Unicode text

solution

Use iconv to convert file encoding format to gb2312

iconv -f utf-8 -t gb2312 shell.sh > shell2.sh

file shell2.sh again to view the file encoding

linuxsec2.sh: ISO-8859 text

Chinese garbled code problem solved

After reading the above content, is there any further understanding of solving the CentOS8 appearance-bash: garbled code problem? If you still want to learn more, please pay attention to the industry information channel.

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