Click here to Skip to main content
15,895,746 members

How can DigitSubstiution be influenced?

Michael Groeger asked:

Open original thread
I am trying to control whether digits get displayed as native digits on systems having an arabic culture.
To be precise, I try to avoid using native digits, because the display string contains a value that is identifying a radio access technology: 3G.

But the DigitSubstitution property provided by NumberFormatInfo in the System.Globalization namespace doesn't have any effect.
These are the values the property can take:
Context - The digit shape depends on the previous text in the same output. European digits follow Latin scripts; Arabic-Indic digits follow Arabic text; and Thai digits follow Thai text.
None - The digit shape is not changed. Full Unicode compatibility is maintained.
NativeNational - The digit shape is the native equivalent of the digits from 0 through 9. ASCII digits from 0 through 9 are replaced by equivalent native national digits.


The following example illustrates this:
// use arabic-Egypt culture
CultureInfo ci = new CultureInfo("ar-EG");
// set digit substitution to avoid substitution
ci.NumberFormat.DigitSubstitution = DigitShapes.None;
Thread.CurrentThread.CurrentCulture = ci;
Thread.CurrentThread.CurrentUICulture = ci;
// arabic text can be "{0} فقط"
textBox1.Text = string.Format(arabicText, "3G");


Further, it behaves differently when system being used was not installed with an arabic display language, although the characters are available.

I would appreciate any help here.

Best regards,
Michael
Tags: C#, Forms, Localization, Globalization

Plain Text
ASM
ASP
ASP.NET
BASIC
BAT
C#
C++
COBOL
CoffeeScript
CSS
Dart
dbase
F#
FORTRAN
HTML
Java
Javascript
Kotlin
Lua
MIDL
MSIL
ObjectiveC
Pascal
PERL
PHP
PowerShell
Python
Razor
Ruby
Scala
Shell
SLN
SQL
Swift
T4
Terminal
TypeScript
VB
VBScript
XML
YAML

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the http://www.codeproject.com/info/cpol10.aspx.



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900