Solution to the problem that php cannot read csv files in linux

Source: Internet
Author: User
Today, when I used php to read csv files with Chinese characters in Linux, the Chinese characters were not displayed, and I felt that the Chinese language was discriminated against. later I found that I had to add the Chinese language logo. When PHP reads a csv file in the LIUNX environment, the Chinese characters in the csv file are not displayed... today, when I used php to read csv files with Chinese characters in Linux, the Chinese characters were not displayed, and I felt that the Chinese language was discriminated against. later I found that I had to add the Chinese language logo.

When PHP reads a csv file in the LIUNX environment, Chinese characters in the csv file are not displayed ....

Finally, I found a solution. let's share it with you!

Add the following sentence before reading the csv file:

Setlocale (LC_ALL, 'zh _ cn ');

Instantly solved the problem ....

Instance:

 

Note:

// UTF-8

Setlocale (LC_ALL, 'en _ US.UTF-8 ');

// Simplified

Setlocale (LC_ALL, 'zh _ cn ');

Extended knowledge:

The following are common region identifiers:

Zh_CN GB2312

En_US.UTF-8 UTF-8

Zh_TW BIG5

Zh_HK BIG5-HKSCS

Zh_TW.EUC-TW EUC-TW

Zh_TW.UTF-8 UTF-8

Zh_HK.UTF-8 UTF-8

Zh_CN.GBK GBK


Article link:

Save this article for favorites!

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.