Ubuntu Chinese encoding settings

Source: Internet
Author: User
Tags netbeans

Ubuntu uses UTF-8 encoding by default to facilitate global operation. However, the support for Chinese characters is not detailed. Even if it is installed in Chinese by default, no GB * or other support will be automatically added, causing garbled characters when accessing some win text files in Ubuntu.
I. Configure the system environment
Run sudo VI/var/lib/locales/supported. d/ZH
Add the following configuration parameters
Zh_cn.gb18030 gb18030 (the latest Chinese character encoding Character Set, backward compatible with GBK, gb2312)
Zh_cn.gbk GBK (expanded Chinese character encoding, backward compatible with gb2312, and contains all big5 Chinese characters)
Zh_cn.gb2312 gb2312! ")
Zh_cn.gb18031 gb18031. Maybe's heroes who use Google Android SDK need this)
Zh_hk.big5 big5 (traditional)
Zh_tw.big5 big5 (traditional)
Then run sudo locale-gen
The following message is displayed.
Zh_cn.gb18030... Done
Zh_cn.gbk... Done
......
II. The system environment supports GB * Internal Code. However, if you use tools such as VI and gedit to access files, garbled characters will continue. You need to configure different tools to detect the supported encoding.
E.g. vi
Run sudo VI/etc/Vim/vimrc
Add the following configuration parameters
Let & termencoding = & Encoding
Set fileencodings = UTF-8, gb18030, GBK, gb2312, big5
E.g. gedit
Run sudo gconf-editor.
Select apps/gedit-2/preferences/encodings
Find auto_detected and add gb18030, GBK, gb2312, and big5 to values.
OK ~
Thanks to LEC for its support.
The enca tool is very convenient and used to detect file inner code (the premise is that the system environment supports, for example, the environment does not support big5, so it cannot be detected. It has been dizzy for a long time)
Install sudo apt-Get install enca
Use enca filename
This tool is found in Google (http://blog.oolec.com /? P = 79), found around the Earth. Article The author sat down next to me and asked about the problem later. Don't run around.
-----------------------------
Other references:

First of all, this article is mainly intended for Java developers. For Windows development, there is basically no way to port the work environment to ubuntu (of course, it cannot be said, maybe you can try wine later ).


1. Default System Encoding
We know that in Chinese Windows, the default encoding of the system is GBK. From the perspective of Java DevelopmentSource codeCompile, file read and write operations, the default encoding is GBK; and we refer to the general Ubuntu Chinese installation documentation, may be recommended to set the default language as a zh_CN.UTF-8, this will bring about some problems, for example, when I use eclipse in windows, the default encoding of the editor is GBK, but under Ubuntu is the UTF-8, also use eclipse, garbled characters are generated when the Chinese documents in windows are uploaded to Ubuntu. You must manually set the attribute encoding to GBK one by one for normal operations. Some TestsCodeThe default encoding is used to read files. The contents of the files read by these codes also contain garbled characters.
Therefore, it is best to set the system's default encoding to GBK, which is the closest to the development environment in windows. there should be more than one setting method. I used/etc/environment to edit it:

 
Language = "zh_cn: Zh: en_us: en"
Ststst_id3_tag_encoding = GBK
Lang = zh_cn.gbk
Lc_ctyle = zh_cn.gbk


2. Chinese font
By default, the Chinese font after Ubuntu 5.10 is installed is not a dot matrix font. Therefore, it is difficult to visualize small characters, and Chinese bold words cannot be displayed when you browse the Web page. there are too many articles about font beautification on the Internet, some of which are made of Windows fonts; recently, "wenquanyi" (http://wqy.sourceforge.net/) Open Source dot matrix fonts have received a lot of praise, in addition, the dot matrix font is suitable for the display of small characters. I use the latest 0.7 beta version (0.6.9 PCF Update 3) and install it according to the steps in the installation guide of wenquanyi lattice, modified Xorg. conf, FC-Cache-F-V is also executed, and the installation process is still smooth, that is, pay attention to the following points, that is, the font must be placed under the/usr/share/fonts/subdirectory. Otherwise, FC-Cache execution will not work. after installation, You need to configure the default font of the system. Firefox also needs to configure the font. The effect is good (see below ).
3. Java (swing) Program Font
I mainly refer to the simplest method for handling Chinese garbled characters in jdk1.5. Follow the simpler method to create the fallback directory under the $ java_home/JRE/lib/fonts/directory, and install a link to the Chinese TTF font or to the fallback directory.
I downloaded the TTF font of wenquanyi 0.6.9 TTF Update 3, decompress it, copy it to the fallback directory, and then run mkfontdir and mkfontscale to solve the problem; now the buttons and labels in the "open" file dialog box of netbeans or jmeter correctly display Chinese characters.
Install the netbeans 5.0 on Ubuntu:
The "Open project" dialog box with Chinese characters:
After processing, the Chinese dialog box is displayed correctly:

Ubuntu uses UTF-8 encoding by default to facilitate global operation. However, the support for Chinese characters is not detailed. Even if it is installed in Chinese by default, no GB * or other support will be automatically added, causing garbled characters when accessing some win text files in Ubuntu.
I. Configure the system environment
Run sudo VI/var/lib/locales/supported. d/ZH
Add the following configuration parameters
Zh_cn.gb18030 gb18030 (the latest Chinese character encoding Character Set, backward compatible with GBK, gb2312)
Zh_cn.gbk GBK (expanded Chinese character encoding, backward compatible with gb2312, and contains all big5 Chinese characters)
Zh_cn.gb2312 gb2312! ")
Zh_cn.gb18031 gb18031. Maybe's heroes who use Google Android SDK need this)
Zh_hk.big5 big5 (traditional)
Zh_tw.big5 big5 (traditional)
Then run sudo locale-gen
The following message is displayed.
Zh_cn.gb18030... Done
Zh_cn.gbk... Done
......
II. The system environment supports GB * Internal Code. However, if you use tools such as VI and gedit to access files, garbled characters will continue. You need to configure different tools to detect the supported encoding.
E.g. vi
Run sudo VI/etc/Vim/vimrc
Add the following configuration parameters
Let & termencoding = & Encoding
Set fileencodings = UTF-8, gb18030, GBK, gb2312, big5
E.g. gedit
Run sudo gconf-editor.
Select apps/gedit-2/preferences/encodings
Find auto_detected and add gb18030, GBK, gb2312, and big5 to values.
OK ~
Thanks to LEC for its support.
The enca tool is very convenient and used to detect file inner code (the premise is that the system environment supports, for example, the environment does not support big5, so it cannot be detected. It has been dizzy for a long time)
Install sudo apt-Get install enca
Use enca filename
This tool is found in Google (http://blog.oolec.com /? P = 79), found around the Earth, Meng found that the author of the article is sitting next to me, and then find something to ask first, don't blindly run.
-----------------------------
Other references:

First of all, this article is mainly intended for Java developers. For Windows development, there is basically no way to port the work environment to ubuntu (of course, it cannot be said, maybe you can try wine later ).


1. Default System Encoding
We know that in Chinese Windows, the default encoding of the system is GBK. From the perspective of Java Development, it is to perform operations such as Java source code compilation and file read/write, the default encoding is GBK, and we refer to the general Ubuntu Chinese installation documentation, may be recommended to set the default language to zh_CN.UTF-8, this will bring some problems, for example, when I use eclipse in windows, the default encoding of the editor is GBK, but under Ubuntu is the UTF-8, the same is the use of Eclipse, in windows under the Chinese documentation to Ubuntu will generate garbled, you must manually set the attribute encoding to GBK one by one for normal operations. Some test codes also use the default encoding to read files. The files read from these codes also contain garbled characters.
Therefore, it is best to set the system's default encoding to GBK, which is the closest to the development environment in windows. there should be more than one setting method. I used/etc/environment to edit it:

 
Language = "zh_cn: Zh: en_us: en"
Ststst_id3_tag_encoding = GBK
Lang = zh_cn.gbk
Lc_ctyle = zh_cn.gbk


2. Chinese font
By default, the Chinese font after Ubuntu 5.10 is installed is not a dot matrix font. Therefore, it is difficult to visualize small characters, and Chinese bold words cannot be displayed when you browse the Web page. there are too many articles about font beautification on the Internet, some of which are made of Windows fonts; recently, "wenquanyi" (http://wqy.sourceforge.net/) Open Source dot matrix fonts have received a lot of praise, in addition, the dot matrix font is suitable for the display of small characters. I use the latest 0.7 beta version (0.6.9 PCF Update 3) and install it according to the steps in the installation guide of wenquanyi lattice, modified Xorg. conf, FC-Cache-F-V is also executed, and the installation process is still smooth, that is, pay attention to the following points, that is, the font must be placed under the/usr/share/fonts/subdirectory. Otherwise, FC-Cache execution will not work. after installation, You need to configure the default font of the system. Firefox also needs to configure the font. The effect is good (see below ).
3. font of the Java (swing) Program
I mainly refer to the simplest method for handling Chinese garbled characters in jdk1.5. Follow the simpler method to create the fallback directory under the $ java_home/JRE/lib/fonts/directory, and install a link to the Chinese TTF font or to the fallback directory.
I downloaded the TTF font of wenquanyi 0.6.9 TTF Update 3, decompress it, copy it to the fallback directory, and then run mkfontdir and mkfontscale to solve the problem; now the buttons and labels in the "open" file dialog box of netbeans or jmeter correctly display Chinese characters.
Install the netbeans 5.0 on Ubuntu:
The "Open project" dialog box with Chinese characters:
After processing, the Chinese dialog box is displayed correctly:

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.