Garbled characters are found when you open a file and view the content in UNIX.

Source: Internet
Author: User
Tags change settings putty settings

Scenario: A file encoding for UTF-8, UNIX system encoding settings are also UTF-8, through Putty to connect to the Unix server, with VI open the file, displays garbled.

1, view UNIX system encoding (locale command): confirmed as UTF-8

Lang = en_GB.UTF-8
Lc_ctype = en_GB.UTF-8
Lc_numeric = en_GB.UTF-8
Lc_time = "en_GB.UTF-8"
Lc_collate = en_GB.UTF-8
Lc_monetary = en_GB.UTF-8
Lc_messages = "en_GB.UTF-8"
Lc_all= en_GB.UTF-8

If not, you can set the current session encoding to a en_GB.UTF-8 by setting export lc_all = UTF-8

 

2, the file encoding confirmed as UTF-8, UNIX system encoding is also UTF-8, why VI opened after the display of garbled? The problem lies in the putty settings. You also need to set the process of transferring data from UNIX to the local display of putty. The putty menu is change settings --> window --> translation. select 'stored data assumed to be in which character set' as a UTF-8.

 

3. Use VI to open the file and display it normally.

 

* In Windows: If the CMD cannot display Chinese characters or other characters normally, use chcp to modify the parameter. The NNN parameter represents three numbers. The codePage in simplified Chinese is: 936 (Spanish): 1252

 

Syntax
Chcp [nnn]: chcp 936

 

 

 

 

 

 

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.