Linux system to find ways to replace non-UTF-8 encoded files

  
                

UTF-8 is a variable-length character Unicode code for Linux systems that supports multiple languages ​​using UTF-8 code. However, some files are not UTF-8 encoded. At this time, we can use commands to find and replace non-UTF-8 codes. Here is a description of how Linux systems find and replace non-UTF-8 encoded files.

Before you begin, please enca install this package. Enca is a tool for viewing file encoding and conversion file encoding under Linux and other systems.

The following line of Linux commands can find out which files in the current directory are not UTF-8 encoded. I added some restrictions to the file. When using the find command, I excluded the .svn directory in all directories and only looked for files with a .php extension.

Command 1:

jw@~/sqlite>

find . ! -iregex ‘.*\\.svn.*’ -type f -name ‘*.php’ -exec bash -c “enca -L zh_CN {}

Copyright © Windows knowledge All Rights Reserved