===========
How would you actually set up GB18030 for Ubuntu?
sudo vi /var/lib/locales/supported.d/local
add a line
zh_CN.GB18030 GB18030
sudo locale-gen
sudo vi /etc/vim/vimrc
add
let &termencoding=&encoding
set fileencodings=utf-8,gb18030
sudo vi /etc/environment
add
LANGUAGE="zh_CN:zh:en_US:en"
GST_ID3_TAG_ENCODING=GB18030
LANG=zh_CN.GB18030
LC_CTYLE=zh_CN.GB18030
quit wsl and relogin
参考:
https://github.com/mintty/wsltty/issues/224
===============
错误:
locale: Cannot set LC_ALL to default locale: No such file or directory
locale: Cannot set LC_CTYPE to default locale: No such file or directory locale
Failed to set locale, defaulting to C
setlocale: LC_ALL: cannot change locale (en_US.utf8): No such file or directory
解决办法:
yum install glibc-langpack-en.x86_64
yum reinstall glibc-common (好像没用)
dnf install langpacks-en glibc-all-langpacks -y (好像没用)
参考:
https://www.tecmint.com/fix-failed-to-set-locale-defaulting-to-c-utf-8-in-centos/
/usr/share/i18n/locales
/usr/share/i18n/charmaps/
以上命令执行后,i18n目录下仍全空。
安装i18n文件需要执行
# yum whatprovides */i18n (查找资源包,发现是glibc-locale-source)
# yum install glibc-locale-source
locale-gen is not present in Centos/Fedora.
You must use localedef:
localedef -v -c -i en_US -f UTF-8 en_US.UTF-8
但前提是安装了glibc-locale-source,/usr/share/i18n/locales目录下有文件。
参考:
https://unix.stackexchange.com/questions/140299/locale-gen-command-in-centos6
My /usr/share/i18n/locales and /usr/share/i18n/charmaps folders were completely empty. No amount of reinstalling packages seemed to fix this. I finally took the contents of the folder from another instance that was working fine, then ran sudo localedef -i en_US -f UTF-8 en_US.UTF-8 to generate the locale information for me. locale -a now shows en_US as available and all my errors are gone.
参考:
https://serverfault.com/questions/788927/missing-locales-on-centos-7
或
# cat /etc/default/locale
LC_CTYPE="en_US.UTF-8"
LC_ALL="en_US.UTF-8"
LANG="en_US.UTF-8"
# source /etc/default/locale
或
# echo "export LC_ALL=en_US.UTF-8" >> /etc/profile
# source /etc/profile
或
# source /etc/profile.d/lang.sh
ubuntu/debian
# apt install locales --reinstall
错误:
/bin/sh: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
解决办法:localedef -i en_US -f UTF-8 en_US.UTF-8
参考:
https://unix.stackexchange.com/questions/439454/locale-issue-on-newly-centos-install
https://www.cyberciti.biz/faq/failed-to-set-locale-defaulting-to-c-warning-message-on-centoslinux/
https://www.sooele.com/6151.html
[
本帖最后由 linda 于 2024-4-16 17:34 编辑 ]