Interface IShortStringHelper
Provides string functions for short strings such as aliases or URL segments.
Namespace: Umbraco.Cms.Core.Strings
Assembly: Umbraco.Core.dll
Syntax
public interface IShortStringHelper
Remarks
Not necessarily optimized to work on large bodies of text.
Methods
View SourceCleanString(String, CleanStringType)
Cleans a string.
Declaration
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 IShortStringHelper default culture.
CleanString(String, CleanStringType, Char)
Cleans a string, using a specified separator.
Declaration
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 IShortStringHelper default culture.
CleanString(String, CleanStringType, Char, String)
Cleans a string in the context of a specified culture, using a specified separator.
Declaration
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
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. |
CleanStringForSafeAlias(String)
Cleans a string to produce a string that can safely be used in an alias.
Declaration
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 IShortStringHelper default culture.
A safe alias is [a-z][a-zA-Z0-9_]* although legacy will also accept '-', and '_' at the beginning.
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
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. |
CleanStringForSafeFileName(String)
Cleans a string, in the context of the invariant culture, to produce a string that can safely be used as a filename, both internally (on disk) and externally (as a URL).
Declaration
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, in the context of a specified culture, to produce a string that can safely be used as a filename, both internally (on disk) and externally (as a URL).
Declaration
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. |
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.
CleanStringForUrlSegment(String)
Cleans a string to produce a string that can safely be used in an URL segment.
Declaration
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 IShortStringHelper default culture.
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
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. |
SplitPascalCasing(String, Char)
Splits a pascal-cased string by inserting a separator in between each term.
Declaration
string SplitPascalCasing(string text, char separator)
Parameters
Type | Name | Description |
---|---|---|
System.String | text | The text to split. |
System.Char | separator | The separator. |
Returns
Type | Description |
---|---|
System.String | The split string. |
Remarks
Supports Utf8 and Ascii strings, not Unicode strings.