Training
Module
Format alphanumeric data for presentation in C# - Training
Explore basic methods in C# to format alphanumeric data.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Arabic and many other languages have classical shapes for numbers that are different from the conventional western digits most often used on computers. To avoid ambiguity in naming these shapes, this document uses the following names from the Unicode standard.
Unicode name of the digits | Country/region where used |
---|---|
European digits | Europe, the Americas, and many other countries/regions |
Arabic-Indic digits | Arabic countries/regions (although many use European digits) |
Other national digits: Indic digits, Thai digits, and the like | Various countries/regions |
Unicode provides separate code points for each digit shape. Thus, to access special language digit shapes, your application can use the relevant Unicode character codes for the digits above, U+0030 through U+0039. These codes are always displayed with the appropriate shape, subject to font availability.
The Unicode character codes U+0030 through U+0039 nominally represent the European digits 0 through 9, but their digit shape can be altered. GDI and DirectWrite text APIs provide mechanisms for applications to control this behavior. (See, for instance, ScriptApplyDigitSubstitution or IDWriteTextAnalysisSink::SetNumberSubstitution.) The behavior in some shell controls and user interface frameworks may respond to user locale settings for digit substitution; the LOCALE_IDIGITSUBSTITUTION LCTYPE can be used to obtain default digit substitution settings for different locales or the current user's desktop settings for digit substitution.
Native digits are the digit shapes chosen by the user in the Number property sheet in the regional and language options portion of the Control Panel. To find the digit presentation preferred by the user, your application uses the GetLocaleInfo or GetLocaleInfoEx function with the LOCALE_SNATIVEDIGITS constant representing the locale information.
Note
Typically, Unicode digit codes are generated in runtime operating system routines. Therefore, common runtime operating systems must be upgraded for the application to inspect LOCALE_SNATIVEDIGITS appropriately.
The application can use digit substitution to tell the operating system how to print digits U+0030 through U+0039. The LOCALE_IDIGITSUBSTITUTION constant controls this operation.
The ExtTextOut, GetCharacterPlacement, and GCP_RESULTS functions have flags that govern the substitution of Unicode codes U+0030 through U+0039 for the duration of the function call. These flags override regional settings in the Control Panel, but do not reset the settings. Also, they do not override the Unicode codes NADS and NODS. The following flags are available.
Flags | Digits used | Used in |
---|---|---|
ETO_NUMERICSLATIN | European digits | ExtTextOut |
ETO_NUMERICSLOCAL | Digits appropriate to the locale | ExtTextOut |
GCP_NUMERICSLATIN | European digits | GetCharacterPlacement |
GCP_NUMERICSLOCAL | Digits appropriate to the locale | GetCharacterPlacement |
GCPCLASS_LATINNUMBER | European digits | GCP_RESULTS |
GCPCLASS_LOCALNUMBER | Digits appropriate to the locale | GCP_RESULTS |
Training
Module
Format alphanumeric data for presentation in C# - Training
Explore basic methods in C# to format alphanumeric data.