Write a Chinese garbled solution process

Source: Internet
Author: User
Tags current time i18n ssh ssh secure file transfer ssh secure shell

first of all, the phenomenon: The browser display Chinese is garbled.

Why does it show garbled characters?

First: The garbled page corresponds to an HTML file, and the HTML file is also used in the UTF-8 format of the encoding, and the contents of the file display normal, no Chinese garbled problem;

Second: Modify the browser code by the following operation, anyway is always garbled




To eliminate the B (browser) side problem, it should be the S (server) side of the problem, then the SSH Secure Shell Client tool to log on to the Linux server, find the application's deployment directory, and find the corresponding HTML file, Use VI open, is garbled, found the problem, the file itself is garbled, the browser is not strange to show garbled. Next start to solve the problem, simply, I put the local display of normal files through the SSH Secure file Transfer Client tool upload to the server and overwrite the original HTML file, open the browser, re-login, check, incredibly or garbled.

quickly open the HTML file on the server, found the same as the original: Chinese all garbled. There is no substitute for success. Re-replace the operation, while using the LL command to view the HTML file details, the last modification time is exactly the same as the current time, determined to be my local files have been replaced, the results open the browser, the same is garbled, then to the server to view HTML or garbled!


think: Should be an operating system environment problem, the operating system should not support Chinese. With this suspicion, the relevant information about the operating system is viewed, and the results are as follows:

# lsb_release-a
LSB Version:: Base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch
Distributor Id:redhatenterpriseserver
description:red Hat Enterprise Linux Server release 6.5 (Santiago)
release:6.5
Codename:santiago

#vi/etc/sysconfig/i18n
Lang= "en_US. UTF-8 "
Sysfont= "Latarcyrheb-sun16"


To view the character encodings displayed by default, discover:
# echo $LANG
en_US. UTF-8


found a problem. Modify the contents of the/etc/sysconfig/i18n file as:

# vi/etc/sysconfig/i18n
#LANG = "en_US. UTF-8 "
#SYSFONT = "Latarcyrheb-sun16"
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"


to do this again:

# echo $LANG
Zh_cn. GB18030

re-upload the local files to the server to replace the original old files, vi open, Chinese display normal, open the browser, view, garbled problem resolution.

here is a very small episode: After modifying the above configuration, I use VI to open the file, Chinese is normal, but with cat view is still garbled. The solution is simple-Modify the client-side tool SSH Secure Shell client code, as shown in the following figure:




The reason is that cat displays content based on the encoding of the client tool, and VI displays the content based on the encoding of the server.


conclusion: In fact, the operating system is supported in Chinese, but not properly configured to display Chinese. Change the system language to: LANG=ZH_CN. UTF-8 can also.

To view the languages supported by the system, you can use the following command to view: Locale-a.

If later found other Chinese garbled problem, you can do the same.

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.