MySQL Convert latin1 data to UTF8

前端 未结 7 1068
-上瘾入骨i
-上瘾入骨i 2020-12-03 02:30

I imported some data using LOAD DATA INFILE into a MySQL Database. The table itself and the columns are using the UTF8 character set, but the default character set of the d

7条回答
  •  萌比男神i
    2020-12-03 02:49

    Converting latin1 to UTF8 is not what you want to do, you kind of need the opposite.

    If what really happened was this:

    1. UTF-8 strings were interpreted as Latin-1 and transcoded to UTF-8, mangling them.
    2. You are now, or could be, reading UTF-8 strings with no further interpretation

    What you must do now is:

    1. Read the "UTF-8" with no transcode.
    2. Convert it to Latin-1. Now you should actually have the original UTF-8.
    3. Now put it in your "UTF-8" column with no further conversion.

提交回复
热议问题