0

For some reason an old database was storing strings which were normal UTF8 into a table that was latin1 (ISO-8859-1). So the string "međuvremenu" became "meÄ‘uvremenu"

Now, I know there is a way to convert it via mysql query into a normal one, which is:

convert(cast(convert(text using latin1) as binary) using utf8)

What I need is the exact same thing but to do it solely in php, since I cannot temper with this database (otherwise I'd just update the entire column.

I guess it is possible with mb_convert_encoding but didn't have luck so far.

Edit: Do not associate this question with the one that provides mysql solution as I explicitly stated I need php-only solution.

obey
  • 796
  • 7
  • 16
  • 1
    Try `mb_convert_encoding("meÄ‘uvremenu", "Windows-1252", "UTF-8")` if you are looking for pure `php` solution… – JosefZ Dec 15 '20 at 19:16
  • Thanks, it seems thats exactly what I needed. But how is that Windows-1252? – obey Dec 16 '20 at 07:56
  • The `‘` character (U+2018, _Left Single Quotation Mark_) isn't defined in `latin1`. – JosefZ Dec 16 '20 at 13:23

0 Answers0