Ubuntu Chinese garbled--add Chinese character set

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. System-Level

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

To add a Chinese character encoding:

    1. $sudo vim/var/lib/locales/supported.d/local

#添加下面的中文字符集

    1. Zh_cn. GBK GBK
    2. Zh_cn. GB2312 GB2312
    3. Zh_cn. GB18030 GB18030

To make it effective:

    1. $sudo dpkg-reconfigure locales

2. Vim

Although Ubuntu has supported GBK, but the default input/display mode is still UTF-8, to change it requires us to set one by one. Vim is at the forefront.
Open VIM configuration file, location in/ETC/VIM/VIMRC
in which to join

    1. Set fileencodings=utf-8,gb2312,gbk,gb18030
    2. Set termencoding=utf-8
    3. Set ENCODING=GBK


Save exit

    1. Source/etc/vim/vimrc

At this time, VIM will be able to display Chinese correctly.
--------------------------------------------------------------‘

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.
4. pdf

    1. $sudo apt-get Install xpdf-chinese-simplifiedxpdf-chinese-traditional #安装pdf的中文字体
    1. $sudo apt-get Install Poppler-data #安装解决pdf中文显示乱码的软件
    2. $CD/ETC/FONTS/CONF.D
    3. $sudo CP 49-sansserif.conf 49-sansserif.conf_backup #先备份下
    4. $sudo rm 49-sansserif.conf #删除


When you open the PDF file, you can display Chinese correctly.

5. Gedit
By default, when you use the Ubuntu Text Editor (gedit) to open a Chinese encoded text file of type gb18030/gbk/gb2312, it will be garbled.

The reason for this is that Gedit uses an encoding matching list, and only the encodings in this list will match, and the encodings that are not in this list will be garbled. All you have to do is add GB18030 to this matching list.

command-line mode for all Ubuntu users.
Copy the following command to the terminal, and then enter:

Gconftool-2--set--type=list--list-type=string/apps/gedit-2/preferences/encodings/auto_detected "[UTF-8,CURRENT, GB18030,BIG5-HKSCS,UTF-16] "

Graphically, for Ubuntu users and not for Kubuntu/xubuntu users.
You can follow these steps to make your Gedit display Chinese encoded files correctly.

Press ALT-F2 to open the Run Application dialog box.
Type "Gconf-editor" in the text box and press ENTER to open the configuration Editor.
Expand the tree node on the left, locate the/apps/gedit-2/preferences/encodings node, and click it.
Double-click the Auto_detected key on the right to open the Edit Key dialog box.
Click the Add button to the right of the list, enter GB18030, and click the OK button.
At the bottom of the list, a new "GB18030" is added. Click to select it and click the Up button to the right until GB18030 is at the top of the list.
Click the OK button to close the configuration editor.
gedit3.x version Settings

Terminal input Dconf-editor

Expand Org/gnome/gedit/preferences/encodings

Add ' gb18030′ ' to the value of auto-detected, and add it to the back of UFT8;

Add ' gb18030′ to the value of Show-in-menu

Now your gedit should be able to open the GB18030 encoded text file successfully.

Gedit 3.X Version Command set: Gsettings set org.gnome.gedit.preferences.encodings auto-detected "[' UTF-8 ', ' GB18030 ', ' GB2312 ', ' GBK ', ' BIG5 ', ' current ', ' UTF-16 '] "

6. Chinese file name garbled conversion

Because ZH_CN was used before. Gb* now uses ZH_CN. UTF-8, so there is a problem with the file name encoding.
Convmv-f gbk-t Utf-8-R--notest/filepath

Reference:

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

Ubuntu Chinese garbled--add Chinese character set

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.