MySQL Latin characters in legacy db

75 views Asked by At

Hi I have inherited a db which I need to use the data from. Unfortunately some of the text is spanish and has some obvious encoding issues. For example this is a typical string stored in a text field:

Clara introducción a través del transporte de me...

My question is - is there any easy way to transform these characters back to what they were using MySQL/PHP?

Any suggestions appreciated.

2

There are 2 answers

0
Darwin Tech On BEST ANSWER

OK - the answer is utf8_decode() in PHP.

0
atxdba On

After you connect to your database be sure to set the character set you want to communicate in.

This will depend on the library or PDO you're using but something along the lines of mysql_set_charset('utf-8');

Further, when you are printing the output ensure your console is set to UTF8. If you are displaying in a webpage, ensure that pages charset is set correctly via headers and/or meta tags.