Quote from: wordcooper at Feb 20, 2008, 07:15 AM
I don’t know if this is what you are talking about, but I had to do the same thing. I backed up the database in Modx and then opened it in Programmer’s Notepad (or TextWrangler), did a search and replace on all the charsets and changed them to utf8. Then dumped the whole thing back into phpMyAdmin. It worked pretty well.
It sounds like you are already doing some cutting and pasting, so why would your snippet be better? Would it be faster?
Not faster but I think safer. With your method, as I understand it, there may be characters in your database that are stored in Latin1 that would take a different form in UTF-8, but you’re telling the database during the import that they’re in UTF-8 format (which they’re not). So the import is corrupted. For regular ASCII characters, this won’t matter, so you can often get away with it. If there are problem characters there, though (say in an encrypted user or manager password or a blog comment, movie or song title, etc.) it will bite you. I tried your method on a MODx install once and wasn’t able to log in because my password was no longer recognized.
One solution is to use the iconv program on the text file to convert its charset before importing. My snippet, if it ever gets finished, would be an alternative.
See this article, though, for a worst-case scenario of what can happen with your method:
http://www.oreillynet.com/onlamp/blog/2006/01/turning_mysql_data_in_latin1_t.html
Bob