Solve linux garbled _ various Chinese garbled characters in the LinuxCentos System

Source: Internet
Author: User
Tags i18n ssh secure shell
We often encounter a bunch of garbled characters when uploading files from windows to Linux, or when you use the editing software to edit a file and save it, we find that the original file is also garbled. After the file is transmitted, garbled characters solve the problem of copying files from windows to linux is garbled and may want to display Chinese Characters in linux. What should I do?
First, let's test whether Chinese Characters in linux can be properly displayed? A: yes. The problem is obvious. The copied files in windows cannot be displayed, indicating that the formats supported in windows and linux are different.
In linux, UTF-8 is generally used, while in windows, gb2312 is used for file editing. Therefore, Chinese encoding is garbled. To correct this problem, it is actually very easy to convert the file into UTF-8 encoding format and then import it again.
Then use the following CommandConversion:
Iconv-f gb2312-t UTF-8 test.txt> testutf8.tzt
(-F indicates the source code.-t indicates the conversion target, test.txtindicates the source file, and testutf8.txt generates the target encoding file)
Note: Use iconv-l to view the supported encoding formats. You can also add the encoding format:
The default value is utf8.
Command to manually change the configuration file:
Shell> vi/etc/sysconfig/i18n
Change LANG = "zh_CN.UTF-8":
LANG = "zh_CN.GBK"
Save and close the configuration. Run the following command to make the configuration take effect:
Shell> source/etc/sysconfig/i18n
Display the terminal character encoding in 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
The solution to the Garbled text read from the database is DatabaseIn LinuxThe encoding format is specified during the upload stream. The Code is as follows:
FileOutputStream fos = new FileOutputStream (new File (filePath), true );
Writer ut = new OutputStreamWriter (fos, "UTF-8 ");
Out. write (s );
Out. write ("\ n ");
Out. flush ();
Fos. close ();
Out. close ();
Solution:
Vi. bash_pro File
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"
Only change the first one. It seems that the second one is especially important and must be changed.


Solve file garbled editing

A new linux virtual machine was created, and a Chinese garbled problem occurred with VIM. The solution was as follows:
Vi/etc/sysconfig/i18n
Change content
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, the Chinese characters are displayed on the SSH terminal.
The main modification content is zh_CN.GB18030. Note that the content of the VI personality is under the root directory, and pay attention to permissions.
 

Solve the SSH connection garbled Problem

Every time linux is installed, SSH connections are used. garbled characters are displayed in Chinese. 51Testing Software Testing Network
Solution: edit/etc/sysconfig/i18n and change LANG = "zh_CN.UTF-8" to LANG = "zh_CN.GB2312 ″.
& M ^ % k7X6X7IQ051Testing software testing network K! W |, r8cV & r5N
Disconnect and reconnect.

When connecting with SSH software, the Chinese LANGUAGE is garbled: Modify the/etc/sysconfig/i18n file and change it to the following content: 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 and 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 ″
 

Solution to Chinese garbled characters in Linux

Copying files from windows to linux is garbled. What should we do if we want to display Chinese Characters in linux? First, let's test whether Chinese Characters in linux can be properly displayed? A: yes. The problem is obvious. The copied files in windows cannot be displayed, indicating that the formats supported in windows and linux are different.
In linux, UTF-8 is generally used, while in windows, gb2312 is used for file editing. Therefore, Chinese encoding is garbled. To correct this problem, it is actually very easy to convert the file into UTF-8 encoding format and then import it again.
Run the following command to convert the data:
Iconv-f gb2312-t UTF-8 test.txt> testutf8.tzt
(-F indicates the source code.-t indicates the conversion target, test.txtindicates the source file, and testutf8.txt generates the target encoding file)
Note: Use iconv-l to view the supported encoding formats. You can also add the encoding format:
The default value is utf8.
Command to manually change the configuration file:
Shell> vi/etc/sysconfig/i18n
Change LANG = zh_CN.UTF-8:
LANG = "zh_CN.GBK"
Save and close the configuration. Run the following command to make the configuration take effect:
Shell> source/etc/sysconfig/i18n
Display the terminal character encoding in 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 Java Chinese garbled characters in Linux

After JDK 15 ~ Create a fallback directory under/jre/lib/fonts/and bake the font you want to use in java to this directory.
The following method is passed in fc6. Assume that 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
Set C: \ WINDOWS \ Fonts \ simsun. after the configuration of centos5.2 in the/usr/java/jdk1.6.0 _ 03/jre/lib/fonts/fallback folder is completed, the UTF-8 characters are displayed normally.
The connection between putty and ssh secure shell found garbled characters, mainly including executing vim garbled characters and su command garbled characters.
Run the $ locale command to view the result, as shown below:
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
A. Modify/ect/sysconfig/i18n on centos:
LANG = zh_CN.UTF-8 ″
B. In the configuration window of putty, modify windows-> Appearance-> font setting to the new, and enter 10.
Modify the Receive data assumed to be in which character set of Translation:
UTF-8. (Because there is no Chinese Character Set in the down list, GB2312 or cp936 ).
After the modification is completed, putty will normally support Chinese display.
2. For the ssh secure shell version.
A. Change the font to, but it is garbled,
B. Modify/ect/sysconfig/i18n of centos:
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 was found on the internet and written as follows.
The ssh secure shell connection is found to display Chinese characters normally.
Use $ locale to check whether the configuration above is changed to GB18030 encoding.
** However, putty is used for connection, but it turns into garbled characters. I understand that putty still uses utf8 encoding,
When configuring ssh secure shell, centos is changed to gb18030 encoding, so garbled.
C. Go to the server, restart centos, and find that Chinese characters are displayed normally.
3. If you find that there is a problem with ssh secure shell or related problems, reconfigure putty,
For the configuration scheme, refer to the above configuration.
Conclusion:
Because the ssh secure shell window conforms to the window display, it is temporarily set to use the ssh secure shell client.
It is also bound with the ftp upload function, which is relatively convenient.
Change: consider setting up mysql and other places to use UTF-8 encoding. All users still use the putty client, and the system encoding is changed to UTF-8.
 

Related Article

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.