Converting special characters like â€

August 20, 2013 in Blog

Alot of WordPress sites leave the database encoding up to the database and end up with latin encoding rather than utf-8. If you start adding tables to your wordpress database and begin seeing things like ” †appear in your returns, there’s a way to fix it with PHP

After receiving (in this case) tweets from our twitter account and storing them in our wordpress database in a custom table, the returns often had encoding problems, like the ” where quotes should have been, etc.

It’s best to have your database and site using the same encoding, but when you can’t, you can use PHP to convert your strings back to utf-8

$TWS is our new variable

$TWEET is the variable with encoding problems


$TWS = mb_convert_encoding($TWEET,’CP1252′,’UTF-8′);