Search code examples
phputf-8iso-8859-1utf8-decode

How do I convert from UTF8 symbols back to ISO-8859-1?


After getting data from a database as UTF8 my text looks like this (example):

Str\u00f8msveien

This should be

Strømsveien

How do I get my ISO-8859-1 symbols back?

I've tried mb_convert_encoding($jsonstring, "iso-8859-1", "UTF8"); and utf8_decode($jsonstring); none of which worked.


Solution

  • The first string is not UTF-8 encoded, but contains JavaScript escapes. You don't need to convert those, JavaScript can cope with them.