window to Linux filename garbled and file content garbled solution Summary __linux

Source: Internet
Author: User
Tags i18n

Window System general file name encoding for GBK, file content encoding this need to view or set through the editor, find a editplus text editor can handle text content encoding.

Then on the window to display normal files to Linux, often because of Chinese problems led to garbled, such as file names garbled and file content garbled.

To view the encoding of Linux settings:

[Root ~]# Echo $LANG
Zh_cn. UTF-8
[Root ~]# locale
Lang=zh_cn. UTF-8
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=

The door is based on centos6.5 query and settings, before it is set Usa.utf-8, behind which it is set to support Chinese ZH_CN. UTF-8, you need to install a package that supports Chinese

Yum-y Groupinstall Chinese-support  

Modify and set the encoding

[Root ~]# vim/etc/sysconfig/i18n
Lang= "ZH_CN. UTF-8 "

[Root ~]# source/etc/sysconfig/i18n

After the setting above, start the following experiment based on XFTP and Xshell.

Xshell in the file--"attribute-" terminal set the encoding, XFTP temporarily not set.


A, Linux filename garbled.

1, create test directories and test files, the file name with Chinese characters, the contents of the file with Chinese characters. Upload to Linux server via XFTP:


In the xftp inside show Chinese all normal.

2, the following Linux display found the file name garbled. View the current file with the file file name at the same time


Now do a transcoding operation:

CONVMV--notest--nosmart-f gbk-t utf8-r file or directory

-F From what code
-T to change to what code
--nosmart if it's already utf-8 ignored
-R contains all subdirectories

--notest does not add a list of what needs to be converted, do not do the actual conversion, so be sure to add


The above steps have fixed the filename garbled problem, the following is by setting the XFTP encoding corresponding to the Linux code.

3, xftp file--"Properties-" option, set to UTF-8 encoding--File name transfer encoding. This shows the file name is directly uft-8 encoding, Linux display will not be garbled.



Second, the contents of the file garbled.

1, with cat view found content garbled


2. iconv-f gbk-t UTF8 test. Txt-o test. txt

After testing has been the file garbled content successfully transcoding,

At the same time iconv do not do cover when another way of writing iconv-f gbk-t UTF8 haha.txt > Haha.txt.utf8

This writing cannot be overwritten, the original file is empty.



3, the other is usually written sell script, in the window passed over the need for transcoding.

Installation: Yum install-y Dos2unix

Execute related commands Dos2unix xxx.sh



The above two solutions basically solve the window to the Linux file name garbled and file content issues, follow-up encounter new problems to add in.


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.