In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
How to solve the garbled characters in linux? Many people do not understand, today Xiaobian in order to let you know more about the solution of character garbled in linux, so summarize the following content, let's take a look at it.
When remote login linux server uses vim to edit and view files under the terminal, we often encounter all kinds of Chinese garbled problems.
The following settings can basically solve the problem of garbled codes in vim.
First, check the system's support for Chinese.
Locale-a | grep zh_CN
Sample output is as follows
Zh_CN.gbk
Zh_CN.utf8
Vim can only correctly identify the Chinese coding files in the list. If you need to identify Chinese files of other coding types, you need to upgrade the system.
Vi / .bash_profile
Add at the end of the file
Export LANG= "zh_CN.UTF-8"
Export LC_ALL= "zh_CN.UTF-8"
Vim coding-related parameters:
1. Eencoding, which is used to configure the encoding for opening and saving files, but there can only be one value, which is only suitable for an environment where a few files are of the same encoding, so it is generally not used.
2. Fileencodings, which is an enhanced version of fileencoding from the name, can be configured with a variety of different encodings. The common configuration is that after configuration, the text encoding in the list can be correctly read by vim as long as it is legal. It is recommended to configure set fileencodings=utf-bom,utf-8,gbk,gb2312,gb18030,cp936,latin1.
3. Encoding,vim internal coding. After vim reads the file, it is not processed by reading the file encoding, but will be converted to the internal encoding format. This encoding is generally related to the operating system, mostly utf-8 under linux, and gdk under Chinese windows. It is recommended to configure set encoding=utf-8.
4. The termencoding,vim output code, output refers to the output to the operating system or command terminal, etc. The default is consistent with the operating system language code. If you use the linux command terminal, it is recommended that the terminal and the linux system configure the same code, and then configure the same termencoding, otherwise the vim will not be taken care of. However, if the shell does not have a Chinese name file, the configuration terminal can be the same as the termencoding. For windows, it can automatically identify gbk and utf-8. No special configuration is required. Recommended configuration: set termencoding=utf-8
5. Fileformats, which is used to distinguish the operating system, mainly enter\ r\ n.recommended configuration: set fileformats=unix,dos
There are several common cases of garbled codes:
(1) the file in windows environment is garbled when you rz it to linux.
Solution:
1. Use notepad++ to convert the file format to UTF-8 without BOM format or ANSI encoding format before rz
2 、 set encoding=utf-8
(2) if garbled codes occur in the secureCRT or xterm2 editing environment, just adjust the character encoding to GB2312 or UTF-8 in the session options.
(3) garbled code occurs when the log file is edited by vim, in most cases because the format of the log file is GB2312.
Solution: 1.set encoding=GB2312;2 if solution 1 doesn't work, adjust the editing environment of secureCRT or xterm2 to GB2312
(4) the wget download file name is garbled.
Solution: generally add-restrict-file-names=nocontrol, such as wget-- restrict-file-names=nocontrol-m www.xxx.com/
(5) cat file is normal, vim file is abnormal.
Solution: write directly to / etc/vim/vimrc, plus the last line
Set fileencodings=gb2312,utf-8
Set fileencoding=gb2312
Set termencoding=utf-8
On how to solve the linux character garbled should be shared here, of course, not only the above and everyone's analysis, but the editor can ensure its accuracy is absolutely no problem. I hope that the above content can have a certain reference value for everyone, and can be put into practice. If you like this article, you might as well share it for more people to see.
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: 0
*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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.