Windows CSV Files and MySQL
I faced some trouble while trying to import a MS Office (XP) created CSV file to a MySQL database table. Trouble was with certain non English (basically accented) characters and it was coming up as question marks in the phpmyadmin interface after importing it. It turned out that selecting the correct character set (charset) for importing the file to the database will solve this error.
I had to google a little bit to find out the solution. I found the following from http://dev.mysql.com/tech-resources/articles/4.1/unicode.html and this page says
"ISO-8859-1 is the most common character set used for Western languages, and it is extended by the Windows-1252 character set to include some other characters, such as the euro (€) and trademark symbol (™). Because Windows-1252 is a superset of ISO-8859-1, the character set is known as latin1 to MySQL, and there is no distinct ISO-8859-1 character set. This matches the common behavior in web applications, which often treat the two interchangeably."
Here is the fix:
MS Office usually uses the charset windows-1252 which is different from the default MySQL charset UTF-8. So the fix was that, while importing Windows based csv files you should select latin1 as the charset in PhpMyAdmin. But if you have used OpenOffice in windows which gives the option to select the charset at the time of saving the csv file this problem may not arise.
This is a common problem coming in wordpress sites. People usually suspect the wordpress charset as the culprit. But before blaming wordpress, please check your MySQL table, particularly through PhpMyAdmin's web interface.
-------Jagannathan V N / ജഗന്നാഥന് വി എന്
CEO, e-lokam.com / ഇ-ലോകം.കോം
Page last modified on 18th Dec 2011


