0

i imported fields and data from a utf8mb4_unicode_520_ci table to a table with utf8_general_ci fields

But when I go to print I see all the strange characters (in php). How do I convert these fields optimally?

i found this

UPDATE table SET title = CONVERT (CONVERT (CONVERT (title USING utf8mb4) USING binary) USING UTF8)

EDIT: IT WORK. But if I print like this in php I see the strange characters, I have to use utf8_encode to see everything normal. I wish I could do a good encode directly in mysql instead of using utf8_encode in php in all points of the application

Roby Em
  • 7
  • 2
  • Well the utf-8_ character set cannot support all the characters that utf8mb4_ can. So you will loose those characters which are not representable – RiggsFolly Jun 29 '22 at 10:25
  • What error does it give you? – Sami Kuhmonen Jun 29 '22 at 10:33
  • utf8mb4_unicode_520_ci unknown – Roby Em Jun 29 '22 at 10:37
  • *i don't know how to replace latin with `utf8mb4_unicode_520_ci` because it gives me error* Of course. This is a collation. According charset is `utf8mb4` - use this value. – Akina Jun 29 '22 at 11:02
  • Thanks, it worked. but when i print with php i always see strange characters, i have to use utf8_encode to bring everything back to normal. How can I do to convert everything correctly in mysql without having to use utf_8encode in php? @Akina – Roby Em Jun 29 '22 at 11:49
  • The `CHARACTER SET utf8` is missing Emoji, some Chinese characters, and a few other things. `utf8mb4` has those. Why did you downgrade to "utf8"? Start a new Question explaining what got this task started. – Rick James Jun 29 '22 at 15:11
  • For strange characters, see https://stackoverflow.com/questions/38363566/trouble-with-utf8-characters-what-i-see-is-not-what-i-stored – Rick James Jun 29 '22 at 15:11

0 Answers0