Php uses exec to execute unzip to decompress the file. Why are the extracted civilized names in Chinese in a format similar to UTF-8 characters? For example, 2064 php uses exec to execute unzip to decompress the file
Why are the extracted civilized names in Chinese in a format similar to UTF-8 characters?
For example
2064-decompress the sub-file .mp4 to 2064-unzip u526f#u672c.mp4
However, this command is normal after being decompressed through the ubuntu terminal.
How can I solve this problem?
Reply content:
Php uses exec to execute unzip to decompress the file
Why are the extracted civilized names in Chinese in a format similar to UTF-8 characters?
For example
2064-decompress the sub-file .mp4 to 2064-unzip u526f#u672c.mp4
However, this command is normal after being decompressed through the ubuntu terminal.
How can I solve this problem?
Solved
When exec is executed in nginx using php
Echo exec ('locale charmap ')
The encoding is set:
ANSI_X3.4-1968
In the terminal, local charmap displays UTF-8
Even php cli running php shows UTF-8
Which of the following configuration causes nginx?
Set the encoding in the php code.
$ Locale = 'zh _ CN.UTF-8 '; setlocale (LC_ALL, $ locale); putenv ('lc _ ALL ='. $ locale );
The specific principle is expected to be explained by experts.
You can set the PHP file source code to UTF-8. Try: header ("Content-type: text/html; charset = UTF-8 ");