{"id":828,"date":"2009-07-08T09:39:02","date_gmt":"2009-07-08T07:39:02","guid":{"rendered":"http:\/\/code.openark.org\/blog\/?p=828"},"modified":"2009-07-08T10:35:40","modified_gmt":"2009-07-08T08:35:40","slug":"character-sets-latin1-vs-ascii","status":"publish","type":"post","link":"https:\/\/code.openark.org\/blog\/mysql\/character-sets-latin1-vs-ascii","title":{"rendered":"Character sets: latin1 vs. ascii"},"content":{"rendered":"<p>Unless specified otherwise, <strong>latin1<\/strong> is the default character set in MySQL.<\/p>\n<p>What I usually find in schemes are columns which are either <strong>utf8<\/strong> or <strong>latin1<\/strong>. The <strong>utf8<\/strong> columns being those which need to contain multilingual characters (user names, addresses, articles etc.), and <strong>latin1<\/strong> column being all the rest (passwords, digests, email addresses, hard-coded values etc.)<\/p>\n<p>I find <strong>latin1<\/strong> to be improper for such purposes and suggest that <strong>ascii<\/strong> be used instead. The reason being that <strong>latin1<\/strong> implies a European text (with swedish collation). It is unclear for an outsider, when finding a <strong>latin1<\/strong> column, whether it should actually contain West European characters, or is it just being used for ascii text, utilizing the fact that a character in <strong>latin1<\/strong> only requires 1 byte of storage.<!--more--><\/p>\n<p>Well, this is what the <strong>ascii<\/strong> character set is for. When I see an <strong>ascii<\/strong> column, I know for sure no West European characters are allowed; just the plain old a-zA-Z0-9 etc. It is clearer from the schema&#8217;s definition what the stored values should be.<\/p>\n<h4>A note to MySQL<\/h4>\n<p>It&#8217;s been long since the Swedish roots of the company have dictated defaults. New instances should default to either <strong>ascii<\/strong> or\u00a0 <strong>utf8<\/strong> (the latter being the most common and space efficient unicode protocol): character sets that are locale-neutral. Really, how many people realize that when they <strong>ORDER BY<\/strong> a text column, rows are sorted according to Swedish dictionary ordering?<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Unless specified otherwise, latin1 is the default character set in MySQL. What I usually find in schemes are columns which are either utf8 or latin1. The utf8 columns being those which need to contain multilingual characters (user names, addresses, articles etc.), and latin1 column being all the rest (passwords, digests, email addresses, hard-coded values etc.) [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"enabled":false},"version":2}},"categories":[5],"tags":[11,18],"class_list":["post-828","post","type-post","status-publish","format-standard","hentry","category-mysql","tag-configuration","tag-data-types"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p2bZZp-dm","_links":{"self":[{"href":"https:\/\/code.openark.org\/blog\/wp-json\/wp\/v2\/posts\/828","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/code.openark.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/code.openark.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/code.openark.org\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/code.openark.org\/blog\/wp-json\/wp\/v2\/comments?post=828"}],"version-history":[{"count":11,"href":"https:\/\/code.openark.org\/blog\/wp-json\/wp\/v2\/posts\/828\/revisions"}],"predecessor-version":[{"id":944,"href":"https:\/\/code.openark.org\/blog\/wp-json\/wp\/v2\/posts\/828\/revisions\/944"}],"wp:attachment":[{"href":"https:\/\/code.openark.org\/blog\/wp-json\/wp\/v2\/media?parent=828"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/code.openark.org\/blog\/wp-json\/wp\/v2\/categories?post=828"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/code.openark.org\/blog\/wp-json\/wp\/v2\/tags?post=828"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}