问题描述
locale
发现LANG=C
- 当
locale
设置为C
时,系统不会使用UTF-8
编码,可能导致 GUI 或终端显示异常(如出现~A
等乱码字符)。
解决方法
设置正确的 locale
运行以下命令生成并启用 UTF-8
编码的 locale
:
sudo apt update && sudo apt install locales # 确保 locales 已安装
sudo dpkg-reconfigure locales
在菜单中选择:
en_US.UTF-8
(英文 UTF-8)
或 zh_CN.UTF-8
(中文 UTF-8)
然后设置环境变量:
echo 'export LANG=en_US.UTF-8' >> ~/.bashrc
echo 'export LC_ALL=en_US.UTF-8' >> ~/.bashrc
source ~/.bashrc
之后重启即可