According to this question on stackoverflow: Detecting utf8 broken characters in MySQL. I found that this answer had the correct approach. This approach will transform broken chars like the following into the correct utf8 chars:
Ã¡ = á Ã© = é Ã- = í Ã³ = ó Ã± = ñ Ã¡ = Á
The idea is to
- convert back to latin1
- convert to binary
- convert to utf8
At least it worked perfect for my setup, so I added a small script to the my class collection simple-php-classes, which transforms a whole MySQL database in the above way. You can find the script on github. Usage:
You will need PHP5 CLI PDO and PDO Mysql
Require the script:
composer require diversen/simple-php-classes
Create config file
mkdir config touch config/config.ini
Add something like the following to the
; database url url = "mysql:dbname=demo;host=localhost;charset=utf8" ; I am not sure about the next line - some time since i wrote it. db_init = "SET NAMES utf8" ; username username = "root" ; password password = "password"
Make a backup if your database is important!
Run the script:
This page has been viewed 7426 times. First hit: 30-Oct-2015 17:02:20
Share email, Google+, Twitter, Facebook.
comments powered by Disqus