Php uses exec to execute unzip decompression command. The Chinese characters in the file name are UTF-8 strings.

Source: Internet
Author: User
Tags php cli
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 ");

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.