Last active
February 19, 2024 16:09
-
-
Save isotopp/3f3f23f24f2e21e35ffa583768bf6b77 to your computer and use it in GitHub Desktop.
Fix Mojibake
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- the table.the_field contains mojibake | |
update the_table | |
set the_field = | |
case | |
-- conversion may fail, returning NULL. In this case, retain original data | |
when convert(cast(convert(the_field using latin1) as binary) using utf8mb4) is null then the_field | |
-- conversion success -> choose the demojibaked data | |
else convert(cast(convert(the_field using latin1) as binary) using utf8mb4) | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment