{"id":618,"date":"2022-04-01T03:28:19","date_gmt":"2022-04-01T08:28:19","guid":{"rendered":"https:\/\/www.clank.org\/blog\/2022\/04\/01\/out-with-the-latin1-in-with-the-utf8mb4\/"},"modified":"2022-04-01T03:28:19","modified_gmt":"2022-04-01T08:28:19","slug":"out-with-the-latin1-in-with-the-utf8mb4","status":"publish","type":"post","link":"https:\/\/www.clank.org\/blog\/2022\/04\/01\/out-with-the-latin1-in-with-the-utf8mb4\/","title":{"rendered":"Out with the latin1, in with the utf8mb4"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">The MySQL database underneath this blog has been using the <em>latin1<\/em> encoding since the beginning. However, at some point I started posting with Unicode characters encoded with UTF-8. WordPress dutifully stuffed this UTF-8 data into the latin1 columns without complaint. After all, it\u2019s technically valid, even if it\u2019s nonsense.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This wasn\u2019t a problem until I upgraded to MySQL 8.0. Suddenly, characters in a few of my posts were displaying incorrectly. For example, non-breaking spaces in several posts were no longer invisible, showing up as \u201c\u00c5\u201d in odd places. Characters such as \u201c\u00f6\u201d were obliterated.  Worse yet, my posts were a mix of latin1 and UTF-8 encoding.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Thankfully, Nic Jansma developed a <a href=\"https:\/\/github.com\/nicjansma\/mysql-convert-latin1-to-utf8\">solution for this problem<\/a> some time ago. It\u2019s not completely automated, but it helps. If you do this yourself make sure you run the script against a copy of your database, over and over again, until you\u2019ve resolved all of the problems.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">At this point everything has been updated to UTF-8 using the MySQL <em>utf8mb4<\/em> encoding. Please drop me a line if you notice anything that looks messed up.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The MySQL database underneath this blog has been using the latin1 encoding since the beginning. However, at some point I started posting with Unicode characters encoded with UTF-8. WordPress dutifully stuffed this UTF-8 data into the latin1 columns without complaint. After all, it\u2019s technically valid, even if it\u2019s nonsense. This wasn\u2019t a problem until I [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[4],"tags":[73,45,31,19],"class_list":["post-618","post","type-post","status-publish","format-standard","hentry","category-geekstuff","tag-mysql","tag-resolution","tag-technical-discussion","tag-wordpress"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p706FA-9Y","jetpack-related-posts":[],"jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/www.clank.org\/blog\/wp-json\/wp\/v2\/posts\/618","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.clank.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.clank.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.clank.org\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.clank.org\/blog\/wp-json\/wp\/v2\/comments?post=618"}],"version-history":[{"count":0,"href":"https:\/\/www.clank.org\/blog\/wp-json\/wp\/v2\/posts\/618\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.clank.org\/blog\/wp-json\/wp\/v2\/media?parent=618"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.clank.org\/blog\/wp-json\/wp\/v2\/categories?post=618"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.clank.org\/blog\/wp-json\/wp\/v2\/tags?post=618"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}