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