docker中安裝中文字符集

2022-06-30 10:03:10 字數 1839 閱讀 4104

[root@5434211632bc /]# history

1 yum install -y kde-l10n-chinese

2 yum reinstall -y glibc-common

3 rpm -qa | grep glibc-common-2.17-222.el7.x86_64

4 yum groupinstall "fonts" -y

5 yum install -y system-config-language

6 localedef -c -f utf-8 -i zh_cn zh_cn.utf8

# 定義字符集

7 localedef -c -f gbk -i zh_cn zh_cn.gbk

8 localedef -c -f gb2312 -i zh_cn zh_cn.gb2312 9 locale -a 10 cat /etc/locale.conf 11 echo 'lang="zh_cn.utf-8"' > /etc/locale.conf

# 修改系統字符集

12 cat /etc/locale.conf 13 source /etc/locale.conf 14 echo 'export lc_all="zh_cn.utf8"' >> /etc/profile 15 source /etc/profile 16 locale 17 history

第15步驟時若報錯誤:

bash: warning: setlocale: lc_all: cannot change locale (zh_cn.utf8): no such file or directory bash: warning: setlocale: lc_all: cannot change locale (zh_cn.utf8): no such file or directory

解決辦法:

可能是執行localedef -c -f utf-8 -i zh_cn zh_cn.utf8步驟時,寫成了

localedef -c -f utf-8 -i zh_cn zh_cn.utf-8

如果還亂碼,執行以下命令:

[root@

650da1307bb1 fonts]

# cd /usr/share/fonts/

[root@

650da1307bb1 fonts]

# fc-cache -fv

#### 生成映象 ##########

docker commit -m

'test'

e265924baa80 centos:

7-utf8

########### dockerfile ##############################################

from centos:

7run

ln -sf /usr/share/zoneinfo/asia/shanghai /etc/localtime \

&& yum -y install kde-l10n-chinese \

&& yum -y reinstall glibc-common \

&& localedef -c -f utf

-8-i zh_cn zh_cn.utf

-8\

&& echo

'lang="zh_cn.utf-8"'

> /etc/locale.conf \

&& source /etc/locale.conf \

&& yum clean all

env lang=zh_cn.utf

-8\

lc_all=zh_cn.utf

-8參考

中文字符集

gb2312 1980年 16位字符集,收錄有6763個簡體漢字,682個符號,共7445個字元。優點 適用於簡體中文環境,屬於中國國家標準,通行於大陸,新加坡等地也使用此編碼 缺點 不相容正體中文,其漢字集合過少。gbk 1995年 16位字符集,收錄有21003個漢字,883個符號,共21886...

設定中文字符集

目錄 二 漢字的編碼 三 設定linux的字符集 四 lang環境變數 五 修改客戶端的字符集 六 字符集轉換工具 七 應用經驗 字元編碼是一種法則,在數字與符號之間建立的對應關係。不同的國家有不同的語言,包含的文字 標點符號 圖形符號各有不同。例如在ascii編碼中,用數字97表達字元 a 與字符...

mysql中文字符集問題

mysql分為客戶端,伺服器端!客戶端的字符集gbk 這是不可變的 而伺服器端能識別基本所有的字符集 這麼多種字符集!為了避免中文亂碼的問題 我們可以告訴伺服器端 我們的客服端是什麼字符集!set character set client gbk 而且還要告訴伺服器返回的資料的字符集是什麼?set ...