How can I solve the problem of converting ANSI encoding to UTF8 encoding?

Source: Internet
Author: User
I want to convert ANSI encoding to UTF8 encoding to realize code. most of the systems I developed using php run in unix, and all the codes are utf8 (databases and webpages ), however, garbled characters often occur when reading files uploaded by windows, because the file encoding in windows is ansi. This requires conversion. First, I cannot ask the user to switch. Second, many php systems on unix do not support the mbstring module. In addition, some virtual spaces require ANSI encoding to UTF8 encoding implementation code.
Most of the systems I developed using php run in unix environments, and all the codes are utf8 (databases and webpages). However, I often read files uploaded by windows operating systems with garbled characters, the reason is that the file encoding in windows is ansi. This requires conversion.
First, I cannot ask the user to switch.
Second, many php systems on unix do not support the mbstring module. In addition, some virtual spaces do not allow any settings, not to mention adding components. So I need to manually write a conversion function to read the ansi file correctly.
Please code. thank you.

------ Solution --------------------
Iconv () does not work?
------ Solution --------------------
Provides an upload page to convert iconv from GBK to utf8.

The existing data in the database seems to have to be exported for encoding, and then iconv. then, import the data back and perform manual operations.

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.