Reprint--Change Ubuntu default encoding to GBK

Source: Internet
Author: User

After Ubuntu supports Chinese (see the previous article), the default is UTF-8 encoding, while the Chinese version of Windows is GBK encoded by default. For consistency, the default encoding for Ubuntu is usually changed to GBK. Of course you can not change, but this will make it very inconvenient for us to share files between the two systems, and the files shared by Samba will always appear garbled. It is not always possible to pass the file every time the human flesh transcoding.

Ubuntu transcoding needs to be divided into several sections, respectively:

1) Let Ubuntu support GBK

Ubuntu does not support GBK by default. If you do not change this, subsequent steps will not take effect.

A) Modify the configuration file # Vi/var/lib/locales/supported.d/local Add the following two lines at the end, save exit: ZH_CN. GBK GBKZH_CN. GB2312 GB2312 b) Update local# dpkg-reconfigure--force locales 2) Let vim default GBK input Although Ubuntu already supports GBK, the default input/display mode is still UTF-8, If we want to change, we need to set it up. Vim is at the forefront.

Before this, make sure your VI upgrade to VIM, and sometimes the system comes with VI, not VIM, can be upgraded by the following command
# Apt-get Install Vim


Open VIM Global configuration file

# VIM/ETC/VIM/VIMRC

Add the following lines to the end of the file:

Let &termencoding=encoding

Set FILEENCODINGS=UTF-8,GB2312,GBK
Set ENCODING=GBK

3) let terminal default GBK

Although Vim has been able to write/open the GBK file, we found that the cat <filename> was still garbled. At this point we need to change the default encoding for terminal.


On the terminal panel, select Termianl-->set character encoding-->add or remove from the menu bar, then select GB2312 or GBK on the left, and add to the right, close. Then on the terminal panel termianl-->set character encoding selected the added Chinese encoding, then can display Chinese correctly.

(If you are logged in with SECURECRT, change it in Session-->terminal-->default encoding)

The above contents are respectively referenced from:

Http://wenku.baidu.com/view/99b9b80ef12d2af90242e64d.html

Http://hi.baidu.com/%CB%E6%CB%AE%C1%F7%D2%E2/blog/item/f4e7b3ccb2d0460901e9283a.html

Http://blog.sina.com.cn/s/blog_77bb63650100wv7b.html

Transferred from: http://blog.csdn.net/zbunix/article/details/8948139

Reprint--Change Ubuntu default encoding to GBK

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.