{"id":88,"date":"2012-03-15T11:20:00","date_gmt":"2012-03-15T11:20:00","guid":{"rendered":"http:\/\/sdi.thoughtstorms.info\/?p=88"},"modified":"2012-03-15T11:20:00","modified_gmt":"2012-03-15T11:20:00","slug":"unicode","status":"publish","type":"post","link":"https:\/\/blog.thoughtstorms.info\/?p=88","title":{"rendered":"Unicode"},"content":{"rendered":"<div dir=\"ltr\" trbidi=\"on\">OK. I&#8217;m\u00a0<a href=\"http:\/\/stackoverflow.com\/questions\/9693699\/python-json-and-unicode\/9693795\">an idiot<\/a>.<\/p>\n<div><\/div>\n<div>So here&#8217;s today&#8217;s BIG Unicode lesson; understand this and, maybe, half your troubles will evaporate.<\/div>\n<div><\/div>\n<div><span>Unicode is NOT a &#8220;code&#8221;.<\/span><\/div>\n<div><\/div>\n<div>No. Unicode is a kind of platonic ideal of which everything else is an &#8220;encoding&#8221;.<\/div>\n<div><\/div>\n<div>ASCII is an encoding. UTF-8 is an encoding. That weird character set you got with Portuguese accented letters is an encoding.<\/div>\n<div><\/div>\n<div>Hence the verb &#8220;<b>encode<\/b>&#8221; means to turn a Unicode string into a byte string.<\/div>\n<div><\/div>\n<div>And &#8220;<b>decode<\/b>&#8221; means to turn a byte string (say one imported from another application) back into the pure Unicode.\u00a0<\/div>\n<div><\/div>\n<div>I repeat.\u00a0You DO NOT <i>encode<\/i> byte-strings into Unicode-strings. You <i>decode<\/i> them into Unicode. And then you re-<i>encode<\/i> them when you want to export them (as, say, XML or JSON).<\/div>\n<div><\/div>\n<div>read &#8211;> decode &#8211;> do stuff in your app &#8211;> encode &#8211;> write<\/div>\n<div><\/div>\n<div>Thanks &#8230; that&#8217;s all.<\/div>\n<div><\/div>\n<div><\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>OK. I&#8217;m\u00a0an idiot. So here&#8217;s today&#8217;s BIG Unicode lesson; understand this and, maybe, half your troubles will evaporate. Unicode is NOT a &#8220;code&#8221;. No. Unicode is a kind of platonic ideal of which everything else is an &#8220;encoding&#8221;. ASCII is an encoding. UTF-8 is an encoding. That weird character set you got with Portuguese accented [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[476],"class_list":["post-88","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-unicode"],"_links":{"self":[{"href":"https:\/\/blog.thoughtstorms.info\/index.php?rest_route=\/wp\/v2\/posts\/88","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.thoughtstorms.info\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.thoughtstorms.info\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.thoughtstorms.info\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.thoughtstorms.info\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=88"}],"version-history":[{"count":0,"href":"https:\/\/blog.thoughtstorms.info\/index.php?rest_route=\/wp\/v2\/posts\/88\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.thoughtstorms.info\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=88"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.thoughtstorms.info\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=88"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.thoughtstorms.info\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=88"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}