Figuring out when digit substitution is applied

by Michael S. Kaplan, published on 2005/09/09 10:38 -04:00, original URI: http://blogs.msdn.com/b/michkap/archive/2005/09/09/462920.aspx


A developer at Microsoft recently asked me the following:

In control panel -> Regional options, the short date sample some times show national digit shapes. Is there any way, I can find out using an api which digit shape is used in the short date example of regional options?

The most important place to look is at GetLocaleInfo and specifically the LCTYPE values LOCALE_IDIGITSUBSTITUTION and LOCALE_SNATIVEDIGITS:

LOCALE_IDIGITSUBSTITUTION
Windows 2000/XP: Determines the shape of the digits. For example, Arabic, Thai, and Indic digits have classical shapes different from western digits. The specifier can be one of these values.
Value Meaning
0 Context - the shape depends on the previous text in the same output.
1 None/Arabic - gives full Unicode compatibility.
2 Native - national shapes determined by LOCALE_SNATIVEDIGITS.
LOCALE_SNATIVEDIGITS
Native equivalents to ASCII zero through 9.

Regional and Language Options uses GetDateFormat to get the formatted string and it is Uniscribe that takes the string when it is rendered and decides what to substitute, as appropriate.

You see, it is Uniscribe and more specifically the ScriptApplyDigitSubstitution and ScriptRecordDigitSubstitution functions (plus the supporting SCRIPT_DIGITSUBSTITUTE structure). Since Uniscribe has shipped in the box for every version of Windows since Windows 2000, the information about when and how to substitute digits is indeed valuable, and the Uniscribe implementation proves it. You can use these functions to do all of the "heavy lifting" for figuring out how to handle digits in a wide variety of situations....

 

This post brought to you by "" (U+0e59, a.k.a. THAI DIGIT NINE)


no comments

referenced by

2010/11/12 Suddenly, in a bit more time than a blink of an eye, "standards support" becomes "less i18n support"

2008/10/02 When swimming in a sea of CONTEXT, applications can drown (and there is no lifeguard)

2007/02/14 Nothing seems to be parsing the crap out of *this* number

2006/06/18 The Phantom of the Digits

2006/04/26 How to NOT Parse Unicode Digits, or How to: Parse Unicode Digits... NOT!

2006/02/22 And the digits just keep on coming

2006/01/18 Digits -- there is no substitute

go to newer or older post, or back to index or month or day