Reprinted -- changed the ubuntu default encoding to GBK and ubuntugbk.

Source: Internet
Author: User

Reprinted -- changed the ubuntu default encoding to GBK and ubuntugbk.

After Ubuntu supports Chinese (see the previous article), the default is UTF-8 encoding, while the Windows Chinese version is GBK encoding by default. For consistency, the default encoding of Ubuntu is usually changed to GBK. You can also leave it unchanged, but this will make it very inconvenient for us to share files between the two systems, and there will always be garbled files shared by Samba. You cannot transcode a file once after it is uploaded.

 

Ubuntu transcoding is divided into several parts:

1) make Ubuntu support GBK

Ubuntu does not support GBK by default. If this parameter is not changed, the subsequent steps will not take effect.

A) modify the configuration file # vi/var/lib/locales/supported. add the following two lines to the end of d/local and save and exit: zh_CN.GBK GBKzh_CN.GB2312 GB2312 B) update local # dpkg-reconfigure -- force locales 2) to allow VIM to input GBK by default. Although Ubuntu already supports GBK, but the Default Input/display method is still UTF-8, to change it needs to be set one by one. VIM bears the brunt.

Before that, make sure that your vi is upgraded to vim. Sometimes the system comes with vi instead of vim. You can use the following command to upgrade it:
# Apt-get install vim


Open the VIM global configuration file

# Vim/etc/vim/vimrc

 

Add the following lines at the end of the file:

Let & termencoding = encoding

Set fileencodings = UTF-8, gb2312, gbk
Set encoding = gbk

 

3) set Terminal to GBK by default.

Although VIM is able to write/Open GBK files, we still find garbled characters in cat <filename>. In this case, we need to change the default encoding method of Terminal.


On the terminal panel, choose termianl --> set character encoding --> add or remove from the menu bar, select GB2312 or GBK on the left, add it to the right, and close it. Then, select the added Chinese encoding in termianl --> set character encoding on the terminal panel, and then the Chinese will be displayed normally.
 

(If you use SecureCRT to log on, change it in Session --> Terminal --> Default Encoding)

 

For the above content, refer:

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

 

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.