Class Utf8ToAsciiConverter
Provides methods to convert Utf8 text to Ascii.
Inheritance
System.Object
Namespace: Umbraco.Cms.Core.Strings
Assembly: Umbraco.Core.dll
Syntax
public static class Utf8ToAsciiConverter
Remarks
Tries to match characters such as accented eg "é" to Ascii equivalent eg "e".
Converts all "whitespace" characters to a single whitespace.
Removes all non-Utf8 (unicode) characters, so in fact it can sort-of "convert" Unicode to Ascii.
Replaces symbols with '?'.
Methods
View SourceToAsciiCharArray(String, Char)
Converts an Utf8 string into an array of Ascii characters.
Declaration
public static char[] ToAsciiCharArray(string text, char fail = '?')
Parameters
Type | Name | Description |
---|---|---|
System.String | text | The text to convert. |
System.Char | fail | The character to use to replace characters that cannot properly be converted. |
Returns
Type | Description |
---|---|
System.Char[] | The converted text. |
ToAsciiString(ReadOnlySpan<Char>, Char)
Converts an Utf8 string into an Ascii string.
Declaration
public static string ToAsciiString(ReadOnlySpan<char> text, char fail = '?')
Parameters
Type | Name | Description |
---|---|---|
ReadOnlySpan<System.Char> | text | The text to convert. |
System.Char | fail | The character to use to replace characters that cannot properly be converted. |
Returns
Type | Description |
---|---|
System.String | The converted text. |
ToAsciiString(String, Char)
Declaration
public static string ToAsciiString(string text, char fail = '?')
Parameters
Type | Name | Description |
---|---|---|
System.String | text | |
System.Char | fail |
Returns
Type | Description |
---|---|
System.String |