Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to solve the problem of garbled code in Linux system after SecureCRT connects to linux server?

2025-03-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains the "Linux system encountered SecureCRT connected to the linux server after the garbled problem how to solve", the article explained the content is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in-depth, together to study and learn "Linux system encountered SecureCRT connected to the linux server after the garbled problem how to solve" it!

Users in Linux systems sometimes encounter garbled codes after SecureCRT connects to the linux server, so how can we solve this problem? In fact, the method is not difficult. Let's take a look at it with the editor now.

Problem: Chinese characters are displayed as garbled (the current system code is UTF-8,CRT and UTF-8)

Principle: keep the coding format of file, system and CRT consistent.

Solution:

Method 1:

A. View the encoding format of the file

You can view file encodings directly in Vim

: set fileencoding

Fileencoding=latin1

Use the command to view the file encoding

# file Mysql2.txt

Mysql2.txt: ISO-8859 text, with CRLF line terminators

ISO-8859 is also known as Latin or "Western European language"

B. Check the format of the encoding used by the Linux system, and modify the editing of the system to en_US (if you see the file edited to UTF-8 or GBK, etc., change it to UTF-8 or GBK, etc.)

# LANG=en_US

# echo $LANG

En_US

C. Modify and modify the settings of Secure CRT (if you see the file edited to UTF-8 or GBK, etc., change it to UTF-8 or GBK, etc.)

Right-click-Select the properties of session to view and modify to default

Method 2:

A. View the encoding format of the file

You can view file encodings directly in Vim

: set fileencoding

Fileencoding=latin1

Use the command to view the file encoding

# file Mysql2.txt

Mysql2.txt: ISO-8859 text, with CRLF line terminators

ISO-8859 is also known as Latin or "Western European language"

Because latin1 is a very loose encoding method, any text obtained by encoding will not fail to decode with latin1-of course, the result of decoding is naturally "garbled".

Enable the system to identify the correct encoding of the file as far as possible (edit ~ / .vimrc file):

# vim ~ / .vimrc

Set encoding=utf-8 fileencodings=ucs-bom,utf-8,cp936

Set fileencodings=ucs-bom,utf-8,cp936,gb18030,big5,euc-jp,euc-kr,latin1

After setting up, you can let vim automatically identify the file encoding (can automatically identify UTF-8 or GBK encoded files), in fact, according to the coding list provided by fileencodings attempt, if you do not find a suitable encoding, using latin-1 (ASCII) coding to open.

Check the code again

: set fileencoding

Fileencoding=cp936

At this time, you should be able to display Chinese normally when you see vim, but not when you see cat.

B. Transcode the file and convert the cp938 format into UTF-8 (no error will be reported when transferring directly from latin1, but it will still be messy)

# iconv-f cp936-t UTF-8 Mysql2.txt-o Mysql8.txt

-f: from

-t: to

-o: output

C. Check the format of the encoding used by the Linux system, and modify the editing of the system to en_US.UTF-8

# LANG=en_US.UTF-8

# echo $LANG

En_US.UTF-8

D. Modify and modify the settings of Secure CRT

Right-click-Select the properties of session to view and modify to UTF-8

If you encounter the same problem when using a Linux computer, use this method to make your SecureCRT connect to the linux server smoothly.

Thank you for your reading, the above is the "Linux system encountered SecureCRT connected to the linux server after the garbled problem how to solve" the content, after the study of this article, I believe that the Linux system encountered SecureCRT connected to the linux server after the garbled problem how to solve this problem has a more profound experience, the specific use of the situation also needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 250

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report