CentOS8 - bash: garbled characters and solutions

CentOS8 - bash: garbled characters and solutions

This situation usually occurs because the Chinese language pack is not installed or there is a problem with the default language setting.
View the current locale
echo $LANG
Found to be
zh_TW.UTF-8
However, if the Chinese language pack is not installed or enabled, garbled characters will appear.

Enter LANG=en_US to set the display to English. This command takes effect immediately but not permanently. See below for permanent effect.
At this point, enter the command again to see the English error message

If you really need Chinese prompts, you can install it like this:
yum groupinstall chinese-support
Set the local default locale
vim /etc/locale.conf add
LANG="zh_TW.UTF-8"
Immediate and permanent effect
source /etc/locale.conf
Enter locale to view the local language environment

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

Note that my language environment is Taiwan Traditional Chinese, and the simplified Chinese language should be changed from TW to CN

Appendix: Let's take a look at the solution to Chinese garbled characters in the shell script that displays utf-8 encoding format in centos

Problem phenomenon

The shell script I wrote was saved in utf-8 encoding format, but when uploaded to centos, it was displayed as garbled characters

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

shell.sh: UTF-8 Unicode text

Workaround

Use iconv to convert the file encoding format to gb2312

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

Run file shell2.sh again to view the file encoding

linuxsec2.sh: ISO-8859 text

The Chinese garbled characters problem has been solved

This is the end of this article about the CentOS8-bash: garbled code problem. For more related centos bash garbled code content, please search 123WORDPRESS.COM's previous articles or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future!

<<:  Example analysis of the principle and solution of MySQL sliding order problem

>>:  jQuery implements HTML element hiding and display

Recommend

MySQL 5.7.27 installation and configuration method graphic tutorial

The installation tutorial of MySQL 5.7.27 is reco...

JavaScript jigsaw puzzle game

This article example shares the specific code of ...

Detailed explanation of the use of various MySQL indexes

1. Slow query log 1.1 MySQL log types Logs are us...

Why Google and Facebook don't use Docker

The reason for writing this article is that I wan...

How MySQL handles implicit default values

Some students said that they encountered the prob...

Detailed explanation of the process of installing MySQL on Ubuntu 18.04.4

Let's take a look at the process of installin...

How to set static IP in centOS7 NET mode

Preface NAT forwarding: Simply put, NAT is the us...

SQL to implement time series dislocation restoration case

Table of contents 1. Requirements description 2. ...

Solutions to Files/Folders That Cannot Be Deleted in Linux

Preface Recently our server was attacked by hacke...

Analysis of the configuration process of installing mariadb based on docker

1. Installation Search the mariadb version to be ...

Implementation of Docker deployment of Django+Mysql+Redis+Gunicorn+Nginx

I. Introduction Docker technology is very popular...

MySQL starts slow SQL and analyzes the causes

Step 1. Enable MySQL slow query Method 1: Modify ...

Install and use Git and GitHub on Ubuntu Linux

Introduction to Git Git is an open source version...

Detailed tutorial on installing Python 3.6.6 from scratch on CentOS 7.5

ps: The environment is as the title Install possi...

Solution to MySQL 8.0 cannot start 3534

MySQL 8.0 service cannot be started Recently enco...