Linux Chinese garbled solution

Source: Internet
Author: User
Tags i18n locale new set ssh secure shell

When it is removed from the database , it is encoded in a character stream when it is stored in a linux file. The code is as follows:
FileOutputStream fos=new FileOutputStream (NewFile (FilePath), true);
Writer ut=new outputstreamwriter (FOS, "UTF-8");
Out.write (s);
Out.write ("\ n");
Out.flush ();
Fos.close ();
Out.close ();
**********************
VI. bash_profile
Export LANG=ZH_CN

vi/etc/sysconfig/i18n
Lang= "en_US. UTF-8 "
Supported= "en_US. Utf-8:en_us:en:zh_cn. GB18030:zh_CN:zh:zh_TW.big5:zh_TW:zh:ja_JP. Utf-8:ja_jp:ja:ko_kr.euckr:ko_kr:ko "
Sysfont= "Latarcyrheb-sun16"
Instead of the first one, it seems that the second one is especially important and must be changed.
***************************************

Method One: Open the Putty Main program, select the Window-〉appearance-〉fontsettings-〉change ..., select the Fixedsys font, and select chinese_gb2312 for the character set. In the window-〉appearance-〉translation, Received data assumed to is in the which character set, use font encoding is changed to UTF-8 if used frequently, Save these settings in the session. Now open putty, after successful login, enter in shell: Export lc_all= ' zh_cn.utf8′

Method Two: Edit/etc/sysconfig/i18n will be the 1th sentence "lang=" ZH_CN. Utf-8″ "to" lang= "ZH_CN. Gb18030″ ", after the completion of the save re-login can be displayed normal


1, console terminal garbled
Add the following on the last line of the/etc/profile file:
Export Lc_all= "ZH_CN. Gb18030″
2, Xwindow terminal garbled
Add the following on the last line of the/etc/sysconfig/i18n file:
Export Lc_all= "ZH_CN. gb18030″+
**************************
Garbled two kinds of situations:
1. Garbled of terminal (pure Shell interface)
Vi/etc/profile
Exportlc_all= "ZH_CN. Gb18030:zh_cn. Gb2312:zh_cn. GBK:zh_CN:en_US. Utf-8:en_us:en:zh:zh_tw:zh_cn. Big5″
Save exit, reboot system can be.
2.x-window (graphical interface) garbled
vi/etc/sysconfig/i18n
Lang= "ZH_CN. Gb18030:zh_cn. Gb2312:zh_cn. GBK:zh_CN:en_US. Utf-8:en_us:en:zh:zh_tw:zh_cn. Big5″
Language= "ZH_CN. Gb18030:zh_cn. Gb2312:zh_cn. GBK:zh_CN:en_US. Utf-8:en_us:en:zh:zh_tw:zh_cn. Big5″
Save reboot ...
*********************
A new set of Linux virtual machine, with Vim appeared in Chinese garbled problem, find the data, the solution is as follows:
vi/etc/sysconfig/i18n
Change the content to
Lang= "ZH_CN. Gb18030″
Language= "Zh_CN.GB18030:zh_CN.GB2312:zh_CN"
Supported= "ZH_CN. GB18030:zh_CN:zh:en_US. Utf-8:en_us:en "
Sysfont= "Lat0-sun16″
In this way, Chinese can be displayed normally in the Ssh,telnet terminal.
Among them, the main modification content mainly is ZH_CN. GB18030, which should pay attention to the VI personality content for the root directory, to pay attention to the permissions
**************************
Each time you install Linux, with SSH connection, Chinese always show garbled. 51Testing Software Testing Network
Workaround: Edit the/etc/sysconfig/i18n, lang= "ZH_CN. Utf-8″ changed to Lang= "ZH_CN. Gb2312″.
&m^%k7x6x7iq051testing software Test Network K! w|,r8cv&r5n
Disconnect the reconnect.
****************************
The solution of Chinese garbled problem in Linux (2008-06-07-12:55:45)
From windows to the file copied to the Linux is garbled, we want to display Chinese under Linux, how to do? We first Test, the Linux under the Chinese can be normal display? A: Yes. So the problem is more obvious, Windows can not be displayed under the copy, Shows that the formats supported under Windows and Linux are not the same.
Linux is generally encoded with utf-8, and when we edit a file on Windows it is gb2312 encoding. So the Chinese encoding will be garbled. It's really easy to correct the problem by simply converting the file into UTF-8 encoded format and then importing it OK.
Then use the following command to convert:
Iconv-f gb2312-t Utf-8 test.txt>testutf8.tzt
(-f is the source code,-T conversion target encoding, test.txt source file, Testutf8.txt generate the target encoding file)
Note: Use Iconv-l to view the System support encoding format. Of course, you can also add the encoding format:
The default is UTF8, if you want to use a different encoding such as GBK
To manually change the configuration file command:
Shell> vi/etc/sysconfig/i18n
Will lang= "ZH_CN. Utf-8″ modified to:
Lang= "ZH_CN. GBK "
Save and close, and run the following command to make the configuration effective:
Shell> source/etc/sysconfig/i18n
Display the terminal character encoding as Simplified Chinese:
Shell> vi/etc/profile.d/chinese.sh
Add the following line: Export LC_ALL=ZH_CN. GBK
Shell> source/etc/profile.d/chinese.sh
*******************************
Solve the problem of Java's Chinese garbled in Linux operating system
After jdk15, just build a fallback directory under ~/jre/lib/fonts/and bake the fonts you want to use in Java into this directory.
The following methods are tested under FC6, assuming the user's JRE path is/usr/java/jdk1.6.0_03/jre/
Cd/usr/java/jdk1.6.0_03/jre/lib/fonts
sudo mkdir fallback
Copy the C:\WINDOWS\FONTS\SIMSUN.TTC to the/usr/java/jdk1.6.0_03/jre/lib/fonts/ After the centos5.2 configuration in the fallback folder is complete, the Chinese can be displayed normally, and the utf-8 character set is supported after viewing.
While putty and SSH Secure Shell connection found garbled, the main performance for the implementation of VIM garbled, su command garbled.
Using the $locale command, the following appears:
Lang=zh_cn. UTF-8
Language=zh_cn:zh
Lc_ctype= "ZH_CN. Utf-8″
Lc_numeric= "ZH_CN. Utf-8″
Lc_time= "ZH_CN. Utf-8″
Lc_collate= "ZH_CN. Utf-8″
Lc_monetary= "ZH_CN. Utf-8″
Lc_messages= "ZH_CN. Utf-8″
Lc_paper= "ZH_CN. Utf-8″
Lc_name= "ZH_CN. Utf-8″
Lc_address= "ZH_CN. Utf-8″
Lc_telephone= "ZH_CN. Utf-8″
Lc_measurement= "ZH_CN. Utf-8″
Lc_identification= "ZH_CN. Utf-8″
Lc_all=
Solution:
1. For putty0.6 version
A. Modifying the/ect/sysconfig/i18n content on CentOS:
Lang= "ZH_CN. Utf-8″
B. Modify the putty in the configuration window windows->appearance->fontsetting for the new song Body, No. 10th Word.
Modify translation receive data assumed to is in which characterset for:
UTF-8. (because there is no Chinese character set in the list, GB2312 or cp936).
When this is done, the putty will normally support Chinese display.
2. For the SSH Secure Shell version.
A. Change the configured font to Arial, but it is still garbled,
B. The/ect/sysconfig/i18n content of the CentOS revision is:
Lang= "ZH_CN. Gb18030″
Language= "Zh_CN.GB18030:zh_CN.GB2312:zh_CN"
Supported= "ZH_CN. GB18030:zh_CN:zh:en_US. Utf-8:en_us:en "
Sysfont= "Latarcyrheb-sun16″
-The above content is found on the internet, according to the written.
The connection SSH Secure Shell is found to display Chinese correctly.
With $locale view, the configuration seen above has become GB18030 encoded.
* * But also with Putty connection, but also become garbled, I understand because Putty still use is UTF8 code,
When configuring the SSH Secure Shell, the CentOS is changed to GB18030 encoded, so garbled.
C. To the server, restart the CentOS, found that the display of Chinese is also normal.
3. If there is a problem with the SSH secure Shell, or a related problem, reconfigure the putty use,
Configuration scenarios can refer to the above configuration.
Conclusion:
Because the SSH Secure Shell window conforms to window display, it is temporarily scheduled to use the SSH Secure Shell client.
And it also bound the FTP upload function, relatively convenient.
Change: Consider building MySQL and many other places using UTF-8 encoding, all still using Putty client, system code changed to Utf-8
##############################################################
Phenomenon: With SSH software connection, Chinese is garbled solution: Modify the/etc/sysconfig/i18n file, change it to the following: Lang= "ZH_CN. Gb18030″language= "ZH_CN. Gb18030:zh_cn. GB2312:ZH_CN "supported=" ZH_CN. Utf-8:zh_cn:zh:en_us. Utf-8:en_us:en "sysfont=" Latarcyrheb-sun16″ #source/etc/sysconfig/i18n Restart the machine, the problem should be solved. CentOS change lang= "ZH_CN. Gb18030″supported= "ZH_CN. GB18030:zh_CN:zh:en_US. Utf-8:en_us:en "sysfont=" lat0-sun16″############################################################# #修改/etc/ Profile Add Export LC_ALL=ZH_CN # for LINUX:ZH_CN EXPORTLANG=ZH_CN # for LINUX:ZH_CN can be resolved.

Linux Chinese garbled solution

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.