简体   繁体   中英

How to convert the character encoding of string to UTF-8 from any encoding in PHP?

I need to convert the character encoding of string str to UTF-8 from any encoding in PHP.

This code: $string = mb_convert_encoding($sring, "utf-8", "auto"); sometimes returns warning: "mb_convert_encoding(): Unable to detect character encoding"

It is impossible to correctly guess the charset for any arbitrary text 100% of the time. Examine the source for clues to the charset (META tag, HTTP header, etc.).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM