Linux 修改编码格式

  • A+
所属分类:Linux
高性能企业级服务器首台5折

通常情况下,云服务器 ECS Linux 默认的编码格式是 utf-8。而安装有些软件可能需要 GBK 等编码支持。本文以 CentOs 6.5 系统为例,建议介绍修改系统编码格式为 zh_CN.GBK 的方法。

方法一


1.vim /etc/profile.d/chinese.sh

2.写入以下内容

  1. 1
    <span class="pln"><span class="hljs-built_in">export</span> LC_ALL</span><span class="pun">=</span><span class="pln">zh_CN</span><span class="pun">.</span><span class="pln">GBK</span>
  2. 1
    <span class="pln">export</span><span class="pun">.</span><span class="pln">GBK</span>

3.wq 保存退出,然后通过指令 source /etc/profile.d/chinese.sh 使配置生效:

4.JPG

方法二


1.编辑配置文件: vim /etc/sysconfig/il8n

2.默认配置为

  1. 1
    <span class="pln">LANG</span><span class="pun">=</span><span class="str"><span class="hljs-string">"en_US.UTF-8"</span></span>
  2. 1
    <span class="pln">SYSFONT</span><span class="pun">=</span><span class="str"><span class="hljs-string">"latarcyrheb-sun16"</span></span>
  1. 将配置修改为:
  1. 1
    <span class="pln">LANG</span><span class="pun">=</span><span class="str"><span class="hljs-string">"zh_CN.GBK"</span></span>
  2. 1
    <span class="pln">SUPPORTED</span><span class="pun">=</span><span class="str"><span class="hljs-string">"zh_CN.UTF-8:zh_CN:zh"</span></span>
  3. 1
    <span class="pln">SYSFONT</span><span class="pun">=</span><span class="str"><span class="hljs-string">"latarcyrheb-sun16"</span></span>

4.使用如下指令使配置生效:

  1. 1
    <span class="pln"><span class="hljs-built_in">source</span> </span><span class="pun">/</span><span class="pln">etc</span><span class="pun">/</span><span class="pln">sysconfig</span><span class="pun">/</span><span class="pln">il8n</span>
  1. 检查当前编码格式:

5.JPG

 

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: