Class DefaultShortStringHelper
New default implementation of string functions for short strings such as aliases or URL segments.
Inheritance
Namespace: Umbraco.Cms.Core.Strings
Assembly: Umbraco.Core.dll
Syntax
public class DefaultShortStringHelper : IShortStringHelper
Remarks
Not optimized to work on large bodies of text.
Meant to replace LegacyShortStringHelper
where/when backward compatibility is not an issue.
NOTE: pre-filters run before the string is re-encoded.
Constructors
View SourceDefaultShortStringHelper(IOptions<RequestHandlerSettings>)
Declaration
public DefaultShortStringHelper(IOptions<RequestHandlerSettings> settings)
Parameters
Type | Name | Description |
---|---|---|
IOptions<RequestHandlerSettings> | settings |
DefaultShortStringHelper(DefaultShortStringHelperConfig)
Declaration
public DefaultShortStringHelper(DefaultShortStringHelperConfig config)
Parameters
Type | Name | Description |
---|---|---|
DefaultShortStringHelperConfig | config |
Methods
View SourceCleanString(String, CleanStringType)
Cleans a string.
Declaration
public string CleanString(string text, CleanStringType stringType)
Parameters
Type | Name | Description |
---|---|---|
System.String | text | The text to clean. |
CleanStringType | stringType | A flag indicating the target casing and encoding of the string. By default, strings are cleaned up to camelCase and Ascii. |
Returns
Type | Description |
---|---|
System.String | The clean string. |
Remarks
The string is cleaned in the context of the default culture.
CleanString(String, CleanStringType, Char)
Cleans a string, using a specified separator.
Declaration
public string CleanString(string text, CleanStringType stringType, char separator)
Parameters
Type | Name | Description |
---|---|---|
System.String | text | The text to clean. |
CleanStringType | stringType | A flag indicating the target casing and encoding of the string. By default, strings are cleaned up to camelCase and Ascii. |
System.Char | separator | The separator. |
Returns
Type | Description |
---|---|
System.String | The clean string. |
Remarks
The string is cleaned in the context of the default culture.
CleanString(String, CleanStringType, Char, String)
Cleans a string in the context of a specified culture, using a specified separator.
Declaration
public string CleanString(string text, CleanStringType stringType, char separator, string culture)
Parameters
Type | Name | Description |
---|---|---|
System.String | text | The text to clean. |
CleanStringType | stringType | A flag indicating the target casing and encoding of the string. By default, strings are cleaned up to camelCase and Ascii. |
System.Char | separator | The separator. |
System.String | culture | The culture. |
Returns
Type | Description |
---|---|
System.String | The clean string. |
CleanString(String, CleanStringType, String)
Cleans a string in the context of a specified culture.
Declaration
public string CleanString(string text, CleanStringType stringType, string culture)
Parameters
Type | Name | Description |
---|---|---|
System.String | text | The text to clean. |
CleanStringType | stringType | A flag indicating the target casing and encoding of the string. By default, strings are cleaned up to camelCase and Ascii. |
System.String | culture | The culture. |
Returns
Type | Description |
---|---|
System.String | The clean string. |
CleanString(String, CleanStringType, String, Nullable<Char>)
Declaration
protected virtual string CleanString(string text, CleanStringType stringType, string culture, char? separator)
Parameters
Type | Name | Description |
---|---|---|
System.String | text | |
CleanStringType | stringType | |
System.String | culture | |
System.Nullable<System.Char> | separator |
Returns
Type | Description |
---|---|
System.String |
CleanStringForSafeAlias(String)
Cleans a string to produce a string that can safely be used in an alias.
Declaration
public virtual string CleanStringForSafeAlias(string text)
Parameters
Type | Name | Description |
---|---|---|
System.String | text | The text to filter. |
Returns
Type | Description |
---|---|
System.String | The safe alias. |
Remarks
The string will be cleaned in the context of the default culture.
Safe aliases are Ascii only.
CleanStringForSafeAlias(String, String)
Cleans a string, in the context of a specified culture, to produce a string that can safely be used in an alias.
Declaration
public virtual string CleanStringForSafeAlias(string text, string culture)
Parameters
Type | Name | Description |
---|---|---|
System.String | text | The text to filter. |
System.String | culture | The culture. |
Returns
Type | Description |
---|---|
System.String | The safe alias. |
Remarks
Safe aliases are Ascii only.
CleanStringForSafeFileName(String)
Cleans a string, in the context of the default culture, to produce a string that can safely be used as a filename, both internally (on disk) and externally (as a URL).
Declaration
public virtual string CleanStringForSafeFileName(string text)
Parameters
Type | Name | Description |
---|---|---|
System.String | text | The text to filter. |
Returns
Type | Description |
---|---|
System.String | The safe filename. |
Remarks
Legacy says this was used to "overcome an issue when Umbraco is used in IE in an intranet environment" but that issue is not documented.
CleanStringForSafeFileName(String, String)
Cleans a string to produce a string that can safely be used as a filename, both internally (on disk) and externally (as a URL).
Declaration
public virtual string CleanStringForSafeFileName(string text, string culture)
Parameters
Type | Name | Description |
---|---|---|
System.String | text | The text to filter. |
System.String | culture | The culture. |
Returns
Type | Description |
---|---|
System.String | The safe filename. |
CleanStringForUrlSegment(String)
Cleans a string to produce a string that can safely be used in an URL segment.
Declaration
public virtual string CleanStringForUrlSegment(string text)
Parameters
Type | Name | Description |
---|---|---|
System.String | text | The text to filter. |
Returns
Type | Description |
---|---|
System.String | The safe URL segment. |
Remarks
The string will be cleaned in the context of the default culture.
Url segments are Ascii only (no accents...).
CleanStringForUrlSegment(String, String)
Cleans a string, in the context of a specified culture, to produce a string that can safely be used in an URL segment.
Declaration
public virtual string CleanStringForUrlSegment(string text, string culture)
Parameters
Type | Name | Description |
---|---|---|
System.String | text | The text to filter. |
System.String | culture | The culture. |
Returns
Type | Description |
---|---|
System.String | The safe URL segment. |
Remarks
Url segments are Ascii only (no accents...).
IsValidFileNameChar(Char)
Declaration
public static bool IsValidFileNameChar(char c)
Parameters
Type | Name | Description |
---|---|---|
System.Char | c |
Returns
Type | Description |
---|---|
System.Boolean |
SplitPascalCasing(String, Char)
Splits a Pascal-cased string into a phrase separated by a separator.
Declaration
public virtual string SplitPascalCasing(string text, char separator)
Parameters
Type | Name | Description |
---|---|---|
System.String | text | The text to split. |
System.Char | separator | The separator, which defaults to a whitespace. |
Returns
Type | Description |
---|---|
System.String | The split text. |
Remarks
Supports Utf8 and Ascii strings, not Unicode strings.