user1634411
user1634411

Reputation: 29

How to decode malformed string in PHP

I have a database full of encoding errors, and am at a loss trying to reverse to find the original data.

This is a sample address from Turkey.

M�¼ze M�¼d�¼rl�¼�Ÿ�¼
Konyalt�± Cad.
Muratpa�Ÿa
Antalya

Update

The problem was two-fold.

  1. Corrupted characters in the original latin1_swedish_ci tables. i.e. characters falling outside of the charset.
  2. Double utf-8 encoding during phpMyAdmin export/import.

A solution for the latter appears to be:

$str = str_replace('?', chr(194).chr(131), $str);
$str = utf8_decode(utf8_decode($str));

This does not solve the original corruption problem, that encoding information has been lost as suggested by @cleong

Upvotes: 2

Views: 1000

Answers (1)

raidenace
raidenace

Reputation: 12826

I assume your database is MySQL. Did you update the encoding and try? First check if you can get it to show up inside MySQL correctly. Set the encoding/collation to UTF-8, query using phpmyadmin or MySQL CLI and check how it looks.

Upvotes: 2

Related Questions