简体   繁体   中英

Converting odd character encoding back to utf-8

I have a database full of strings containing strange characters such as:

Design Tattoo Ãœbungshaut

Mehrflächiges Biozid Reinigungs- & Desinfektionsmittel

Where the Ãœ and ä should be, as I understand, an Ü and à when in proper UTF-8 .

Is there a standard function to revert these multiple characters back to there proper UTF-8 form?

In PHP I have come across $url = iconv('utf-8', 'iso-8859-1', $url); which seems to get close but falls short. Perhaps I have the wrong parameters, but in any case was just wondering how well this issue is know and if there is an established fix?

The original data was taken from the eCommerce system CubeCart which seems to have no problem converting it back to normal text FYI.

The data shown as example is UTF-8 encoded data mistakenly interpreted as ISO-8859-1 (or windows-1252). The problem combinations are in fact “Ü” and “ä” (“Ā” does not appear in German). So apparently what you need to do is to read the data as UTF-8 and display it that way, instead of converting it.

If the database and output is utf-8 it could be because your not using utf-8 as the client character set.

If your using mysqli you can use set_charset or run SET NAMES utf8 as a query before fetching data.

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