(collect) The solution of garbled characters in Linux environment

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.
****************************
Linux Chinese garbled Problem solution (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, Linux under the Chinese can be normal display? A: Yes. So the problem is more obvious, Windows can not be displayed under the copy, indicating that Windows and Linux under the supported format is 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.

(collect) The solution of garbled characters in Linux environment

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.