{"id":1653,"date":"2014-02-26T07:00:00","date_gmt":"2014-02-26T07:00:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/2014\/02\/26\/why-are-leading-digits-converted-to-language-specific-digit-shapes-but-not-trailing-digits-and-how-do-i-suppress-the-conversion-entirely\/"},"modified":"2014-02-26T07:00:00","modified_gmt":"2014-02-26T07:00:00","slug":"why-are-leading-digits-converted-to-language-specific-digit-shapes-but-not-trailing-digits-and-how-do-i-suppress-the-conversion-entirely","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20140226-00\/?p=1653","title":{"rendered":"Why are leading digits converted to language-specific digit shapes, but not trailing digits, and how do I suppress the conversion entirely?"},"content":{"rendered":"<p>If you have a string like <code>12345ABCDE67890<\/code>, and you render it on an Arabic system, you might get <span dir=\"ltr\">&#1632;&#1633;&#1634;&#1635;&#1636;ABCDE67890<\/span>. The leading digits are rendered as Arabic-Indic digits, but the trailing digits are rendered as European digits. What&#8217;s going on here?\n This is a feature known as <i>contextual digit substitution<\/i>. You can specify whether European digits are replaced with native equivalents by going to the <i>Region<\/i> control panel (formerly known as <i>Regional and Language Options<\/i>), clicking on the <i>Formats<\/i> tab, going to <i>Additional settings<\/i> (formerly known as <i>Customize this format<\/i>), and looking at the options under <i>Use native digits<\/i>. The three options there correspond to <a href=\"http:\/\/web.archive.org\/web\/20120119031036\/http:\/\/blogs.msdn.com\/b\/michkap\/archive\/2005\/09\/09\/462920.aspx\"> the three values for <code>LOCAL_IDIGITSUBSTITUTION<\/code><\/a>.\n Programmatically, you can override the user preference (if you know that you are in a special case, like an IP address) by <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/windows\/desktop\/dd317791%28v=vs.85%29.aspx\"> following the instructions in MSDN<\/a>.<\/p>\n<ul>\n<li>Uniscribe: <code>Script&shy;Apply&shy;Digit&shy;Substitution<\/code> <\/li>\n<li>DWrite: <code>IDWrite&shy;Text&shy;Analysis&shy;Sink::Set&shy;Number&shy;Substitution<\/code> <\/li>\n<li>GDI: <code>ETO_NUMERICS&shy;LATIN<\/code> or     <code>ETO_NUMERICS&shy;LOCAL<\/code>. <\/li>\n<\/ul>\n<p> As a last resort, you can stick a Unicode NODS (U+206F) at the beginning of the string to force European digits, or a <!-- A HREF=\"http:\/\/blogs.msdn.com\/b\/michkap\/archive\/2011\/05\/12\/10163685.aspx\" --> Unicode NADS (U+206E) to force national digits.\n <b>Bonus chatter<\/b>: What&#8217;s the point of contextual digit substitution anyway?\n Suppose you have the string &#8220;there are 3 items remaining.&#8221; (Let&#8217;s say that all text in lowercase is in Arabic.) You want this 3 to be rendered in Arabic-Indic digits because it is part of an Arabic sentence. On the other hand, if you have the string &#8220;that&#8217;s a really nice BMW 350.&#8221; you want the 350 to be in European digits since it is part of the brand name &#8220;BMW 350&#8221;.<\/p>\n<p> Contextual digit substitution chooses whether to use Arabic-Indic digits or European digits by matching them to the characters that immediately precede them. (And if no character precedes them, then it uses the ambient language.) <\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you have a string like 12345ABCDE67890, and you render it on an Arabic system, you might get &#1632;&#1633;&#1634;&#1635;&#1636;ABCDE67890. The leading digits are rendered as Arabic-Indic digits, but the trailing digits are rendered as European digits. What&#8217;s going on here? This is a feature known as contextual digit substitution. You can specify whether European digits [&hellip;]<\/p>\n","protected":false},"author":1069,"featured_media":111744,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[25],"class_list":["post-1653","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-code"],"acf":[],"blog_post_summary":"<p>If you have a string like 12345ABCDE67890, and you render it on an Arabic system, you might get &#1632;&#1633;&#1634;&#1635;&#1636;ABCDE67890. The leading digits are rendered as Arabic-Indic digits, but the trailing digits are rendered as European digits. What&#8217;s going on here? This is a feature known as contextual digit substitution. You can specify whether European digits [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/1653","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/users\/1069"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/comments?post=1653"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/1653\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media\/111744"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media?parent=1653"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=1653"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=1653"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}