0

I have a text saved in database like this: $text = 'GrüÃen'; It contains some encoded German characters. How can I get the right format: 'Grußen'

I have tried some kind of php function like this: $output = mb_convert_encoding($text, 'ISO-8859-1', 'UTF-8'); $output = html_entity_decode($text, ENT_COMPAT | ENT_HTML5, 'UTF-8');

  • 2
    The text in your database has been corrupted due to mishandling. Specifically, it appears to have been incorrectly converted between encodings at least once. In order to have a chance at reversing the corruption we'll need to know the intended output encoding, and the _exact_ byte values stored in the database, encoded with either `HEX()` in the query or `bin2hex()` in php as you cannot reliably copy-paste this broken data. – Sammitch Jul 01 '23 at 00:25
  • 2
    In _addition_ to that, you also need to fix how your application handles text to prevent this in the future. See: https://stackoverflow.com/questions/279170/utf-8-all-the-way-through – Sammitch Jul 01 '23 at 00:25
  • There is no reason to use ISO-8859-1 in 2023, unless you're dealing with some legacy system. Is that the case? – Álvaro González Jul 01 '23 at 07:43

0 Answers0