设置 ~/.bash_profile 或 ~/.bashrc 添加下面两句:
export LC_CTYPE=zh_CN.GB2312
export LANG=en_US.UTF-8
其余均保持原有 en_US.UTF-8 不变即可。前提是你装了中文语言包。
注: .bash_profile 为用户登陆时加载的profile, 只在用户登陆时执行
.bashrc 为shell profile,每执行一个 shell, 就会被执行一次
可用 locale 命令查看这些设置值
export LC_CTYPE=zh_CN.GB2312
export LANG=en_US.UTF-8
其余均保持原有 en_US.UTF-8 不变即可。前提是你装了中文语言包。
注: .bash_profile 为用户登陆时加载的profile, 只在用户登陆时执行
.bashrc 为shell profile,每执行一个 shell, 就会被执行一次
可用 locale 命令查看这些设置值
博客介绍了在Shell语言中设置字符编码的方法,通过在~/.bash_profile或~/.bashrc中添加特定语句,设置LC_CTYPE为zh_CN.GB2312,LANG为en_US.UTF-8,其余保持原有设置不变,前提是安装了中文语言包,还说明了两个文件的执行时机及查看设置值的命令。

被折叠的 条评论
为什么被折叠?



