What should I do if the Chinese file name under centos displays garbled characters?

王林
Release: 2020-03-23 11:20:37
Original
3614 people have browsed it

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
Copy after login

2. Transfer Code

convmv -f gbk -t utf-8 -r --notest /home/wwwroot
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!