UTF-8 encoded PHP page calls scandir to generate garbled characters

Source: Internet
Author: User

Manage the newly written graph beds todayProgramThe encoding was changed to the UTF-8 format. I wanted to move closer to foreign standards. The result was just a big problem. Originally, my files were all ANSI. I used notepad to replace them with UTF-8 one by one, then remove the BOM, and I don't know if it's okay except for the problem, but there are some garbled characters. I thought it was wrong when I changed the code, will it make the two types of code combination? I have made it for a long time, and even re-established the files. I am not a zombie, so I will lock the scandir, the garbled characters only appear in the use of this function, but I think it is still wrong. Yesterday this function scanned the Chinese file name and it was okay. Today it is derailed?

I re-created a file test, and it showed that the file name in Chinese is correct and there is no pressure on it. It's crazy for me. In the end, I can't stand it anymore. Listen to the song first, suffocate the feeling, and suddenly think of it, when uploading a file with a Chinese file name yesterday, uploadify will also save the file name as garbled characters. Well, I will try it again. If I use iconv to change the encoding, OK, okay, day, this is a problem, for so long, PHP is ..........

Summary:Because the page encoding is UTF-8, and the file name returned by scandir should be GBK (I don't know if this is the case), there is a problem. You can change the page encoding to GBK, so here we can use iconv to convert it. Ah, the damn code is still the most cute of Qin Shihuang.

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.