开发者

fix database wrong encoded

开发者 https://www.devze.com 2023-04-02 06:34 出处:网络
I have an old site that the encoding is 开发者_Go百科utf8. But the database is latin1. The problem is that all data (thousands) were recorded wrong.

I have an old site that the encoding is 开发者_Go百科utf8. But the database is latin1. The problem is that all data (thousands) were recorded wrong.

Sample of a phrase engraved

verificação de erro na geração dos códigos

Is there any SQL function that transforms all records in the database for the correct coding?


Yes, that is simple :)

INSERT INTO utf8table (utf8column)
    SELECT CONVERT(latin1field USING utf8) FROM latin1table;

http://dev.mysql.com/doc/refman/5.0/en/charset-convert.html

You can also do that with PHP. You can select data, transform it with iconv() functions, and update appropriate fields. Do whaterver you are more confortable with.

0

精彩评论

暂无评论...
验证码 换一张
取 消