Skip to content

Convert latin1/windows-1252 chars to utf8 in mysql database

License

Notifications You must be signed in to change notification settings

Juergen74/latin2utf8

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

latin2utf8

Convert latin1/windows-1252 chars to utf8 in mysql database

Earlier versions of wordpress were using latin-1 as collation for the mysql database, which sometimes leads to problems when moving sites. If you see a lot of chars like "ä" or "ö" instead of "ä" and "ö" – you are most likely a German... :)

This helper class loops through all your tables and replaces them with the apropriate utf8 "umlaut". Before you run this, you should change all your tables and column collation to something like "utf8mb4_unicode_520_ci" (the standard for wordpress), which can be easily done with phpMyAdmin.

Bonus feature: You can add your own "search" and "replace" strings with "addSearchReplace("search", "replace").
Wordpress sometimes is using serialized data. This class will recalculate those serialized strings automatically if there is any search & replace happening, that normally would corrupt this data.

As long as "updateTables(false)" is set to false – nothing will happen, it will only produce a nice preview of all characters found, that will be replaced.
Set "updateTables(true)" to run the conversion.

Recommendation: Be carfull and only use it on a backup of your database in local development environment! :)

Use this class like

include('./latin2utf8.php');

$latin2Utf8 = new Latin2Utf8("wp_test", "jonny", "root");
//$latin2Utf8->addSearchReplace("develop.local", "www.develop.de");
$latin2Utf8->updateTables(false);

About

Convert latin1/windows-1252 chars to utf8 in mysql database

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages