Digits -- there is no substitute

by Michael S. Kaplan, published on 2006/01/18 03:01 -05:00, original URI: http://blogs.msdn.com/b/michkap/archive/2006/01/18/514171.aspx

I have kind of talked about digit substitution now and again since I started with this blog.

And I went on and on about the impressive model for the future in the Is Whidbey's international support finished? post, and after all the work was done in Whidbey to make sure that if you tried to make assignments to the new NumberFormatInfo.NativeDigits property -- there had to be exactly ten, they had  to all have the Nd general category with a value that matched the position the characters were in (so you could not turn 5 into 7 or whatever).

Of course if I only knew then what I know now I may not have worked with people to have such functionality working so hard to validate the input!

Why, you might ask?

Well, it turns out that the values are not used by either Windows or the .NET Framework, at least not in the way that you might think....

You see, both GDI+ and Uniscribe have hardcoded lists of digits, and if you are going through one of them and you have your LOCALE_IDIGITSUBSTITUTION set to context or native and then digit substitution becomes appropiate, it will look at just one of the digits and then use its script characteristics to pick from the hardcoded list of digits.

They arbitrarily decided to go with the DIGIT ONE value since at the time this work was initially done the Tamil script had no TAMIL DIGIT ZERO (it has since been added at U+0be6).

So it really does not matter from the Microsoft point of view what is in NumberFormatInfo.NativeDigits or LOCALE_SNATIVEDIGITS via GetLocaleInfo, other that first digit -- and only then if they know about that digit.

Here is definitely a limitation to be addressed for a future version....

Though in the meantime it is data that is available in applications that want to use the data correctly. No one has to wait for MS to get around to using it right. :-)


This post brought to you by U+0be6, a.k.a. TAMIL DIGIT ZERO

no comments

referenced by

2011/09/28 Whodvethunk it'd be GDI+ injecting a little sanity into digit shenanigans?

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

2010/01/18 Yet another digit substitution[.Net] problem

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

2008/04/21 Windows doesn't let you choose the pinch hitter in digit substitution cases

2007/08/10 I've been to the desert on a dead key with no name

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

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