Chinese garbled characters of uploaded files

Source: Internet
Author: User
The Chinese garbled characters of the uploaded files are all set to utf8. However, after the files are uploaded, garbled characters are found in the file directory, and the file name is converted to GB2312 before uploading, at this time, the file name can display Chinese characters, but the database storage path cannot be inserted. I changed the table to the GB2312 character set. it should be said that, still cannot be inserted? How to upload a file with garbled Chinese characters
All character sets are set to utf8, but after the file is uploaded, a garbled Chinese file name is found in the file directory. then, the file name is converted to GB2312 before the upload. at this time, the file name can display Chinese characters, however, when the database storage path cannot be inserted, I changed the table to the GB2312 character set. it can be done as a matter of fact, or cannot be inserted? What should I do?

File upload garbled

Share:


------ Solution --------------------
This involves two concepts: System encoding and character encoding.
I don't know what system you used before uploading. for windows (after 98), the "gb2312" encoding is actually cp936 (equivalent to GBK) encoding.
The database's character encoding gb2312 and gbk are not the same, and there are many fewer Chinese characters. we should select gbk encoding.

If not, consider other factors. if the server is windows, it is a headache, because php cannot effectively process unicode paths in windows at present-if any character in your full path exceeds the character set, windows uses the mixed encoding record path; * nix records the path in UTF-8 encoding, so the problem is not serious.
------ Solution --------------------
Let's talk about a solution.

Or full use of UTF-8, after the upload in the PHP file and then forced conversion once the upload detection file name is UTF-8 or GBK or GB2312 and then unified conversion to UTF-8

Add an additional GB2312 to the http://www.cnblogs.com/rosenia/archive/2013/05/20/3088146.html array

Then save

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.