Home >Operation and Maintenance >CentOS >What should I do if the Chinese file name under centos displays garbled characters?
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: centos usage tutorial)
The solution is as follows:
1. Install convmv
yum install convmv
2. Transfer Code
convmv -f gbk -t utf-8 -r --notest /home/wwwroot
Introduction to common parameters:
-r Recursively process subfolders
-notest Really perform operations. By default, no real operations are performed on files
–list displays all supported encodings
–unescap can be escaped, such as changing it to a space
-i Interactive mode (ask every conversion to prevent misoperation)
Extensions:
There are many convenient gadgets under Linux to convert encodings:
Text content conversion: iconv
File name conversion: convmv
mp3 tag conversion: python-mutagen
Related video tutorial recommendations: linux video tutorial
The above is the detailed content of What should I do if the Chinese file name under centos displays garbled characters?. For more information, please follow other related articles on the PHP Chinese website!