String.Normalize Method (NormalizationForm)
Returns a new string whose textual value is the same as this string, but whose binary representation is in the specified Unicode normalization form.
Assembly: mscorlib (in mscorlib.dll)
- Type: System.Text.NormalizationForm
A Unicode normalization form.
Return ValueType: System.String
A new string whose textual value is the same as this string, but whose binary representation is in the normalization form specified by the normalizationForm parameter.
The current instance contains invalid Unicode characters.
Some Unicode characters have multiple equivalent binary representations consisting of sets of combining and/or composite Unicode characters. The existence of multiple representations for a single character complicates searching, sorting, matching, and other operations.
The Unicode standard defines a process called normalization that returns one binary representation when given any of the equivalent binary representations of a character. Normalization can be performed with several algorithms, called normalization forms, that obey different rules. The .NET Framework supports the four normalization forms (C, D, KC, and KD) that are defined by the Unicode standard. When two strings are represented in the same normalization form, they can be compared by using ordinal comparison.
To normalize and compare two strings, do the following:
Obtain the strings to be compared from an input source, such as a file or a user input device.
Call the method to normalize the strings to a specified normalization form.
To compare two strings, call a method that supports ordinal string comparison, such as the Compare(String, String, StringComparison) method, and supply a value of StringComparison.Ordinal or StringComparison.OrdinalIgnoreCase as the StringComparison argument. To sort an array of normalized strings, pass a comparer value of StringComparer.Ordinal or StringComparer.OrdinalIgnoreCase to an appropriate overload of Array.Sort.
Emit the strings in the sorted output based on the order indicated by the previous step.
For a description of supported Unicode normalization forms, see System.Text.NormalizationForm.Notes to Callers
The IsNormalized method returns false as soon as it encounters the first non-normalized character in a string. Therefore, if a string contains non-normalized characters followed by invalid Unicode characters, the Normalize method may throw an ArgumentException although IsNormalized returns false.
Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.