How to solve the Linux environment PHP read CSV file, the Chinese can not read the situation

Source: Internet
Author: User
How to solve the Linux environment PHP read CSV file, the Chinese can not read the situation

There is a magical problem when doing a batch import of data!

When PHP reads the CSV file in the LIUNX environment, the Chinese in the CSV file is not displayed ....

Add a sentence before executing the CSV file read:

SetLocale (Lc_all, ' zh_cn ');


In an instant, the problem solved ....

SetLocale (Lc_all, ' zh_cn '); $handle = fopen ("Xxx.csv", "R"), while ($data = Fgetcsv ($handle, 1000, ', ')) {...} Fclose ($handle);


Annotations:

Utf-8setlocale (Lc_all, ' en_US. UTF-8 ');//simplified setlocale (lc_all, ' zh_cn ');

Expand your knowledge about:
The following are the common regional identities
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

  • 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.