How is this website fixing the encoding?

前端 未结 6 1566
情歌与酒
情歌与酒 2021-01-07 11:51

I am trying to turn this text:

×וויר. העתיד של רשתות חברתיות והתקשורת ×©×œ× ×•

Into this text:



        
6条回答
  •  长情又很酷
    2021-01-07 12:01

    Since the issue was a MySQL fault with double-encoded UTF8 strings, MySQL is the right way to solve it.

    Running the following commands will solve it -

    • mysqldump $DB_NAME -u $DB_USER -p -h $DB_HOST.EXAMPLE.NET --add-drop-table --default-character-set=latin1 > export.sql - latin1 is used here to force MySQL not to split the characters, and should not be used otherwise.
    • cp export{,.utf8}.sql - making a backup copy.
    • sed -i -e 's/latin1/utf8/g' export.utf8.sql - Replacing the latin1 with utf8 in the file, in order to import it as UTF-8 instead of 8859-1.
    • mysql $DB_NAME -u $DB_USER -p -h $DB_HOST.EXAMPLE.NET < export.utf8.sql - import everything back to the database.

    This will solve the issue in about ten minutes.

提交回复
热议问题