Problem:
When using ftp to upload files to Linux on Windows, the Chinese name is displayed as garbled characters in the Linux system. Although the Linux env is set to LANG=en_US.UTF-8, and the local Shell client encoding is also set to UTF-8, it is still garbled in the Shell (or accessed through http).
Reason:
The default Chinese encoding of file names in Windows is GBK. After compression or uploading, the file names will still be GBK encoded, while the default file name encoding in Linux is UTF8 due to inconsistent encoding. This leads to the problem of garbled file names. To solve this problem, the file names need to be transcoded.
(Recommended tutorial:linux tutorial)
Solution:
yum install convmv
convmv -f gbk -t utf-8 -r --notest /home/要操作的文件
Common parameters:
-r Recursively process sub-files Folder
-notest actually performs the operation. By default, no real operation is performed on the file.
-list displays all supported encodings
-unescap. You can do some escaping, such as Turn it into a space
-i Interactive mode (ask every conversion to prevent misoperation)
Recommended related video tutorials:linux video tutorial
The above is the detailed content of What to do if the Chinese file name is garbled under Linux. For more information, please follow other related articles on the PHP Chinese website!