Managing User InputGlobal applications pose several special considerations when planning for the manipulation and validation of user input. When attempting to validate non-Latin character user input, it may be necessary to extract single characters in sequence through string indexing, whereas the comparison and sort order of a simple alphabetic sort routine may produce different results depending on the culture used. String IndexingThe Unicode standard supports 32-bit extended characters (surrogate characters) and 32-bit characters that are formed by combining two 16-bit Unicode characters (combined characters), such as an accent mark and the base character to which it applies. In order to evaluate these characters amid other normal input characters, it is sometimes necessary to parse an input string, character by character, for validation, taking into account the fact that some characters may be 16 bit and others 32 bit. The .NET Framework provides support for this type of string manipulation through the System.Globalization.StringInfo class. You can use this class to iterate through the elements in a string by repeatedly calling its MoveNext method. This method returns a zero value when it has exhausted all values in a character string, as shown in this example:
Comparing and Sorting DataCultures sort alphabetical lists in different ways, such as placing numeric characters either before or after alphabetic characters and ordering a character followed by a space as falling either before or after the same character followed by another character. In order to support culture-aware sorting, the .NET Framework includes several features:
|