Links

TextUtils

Wisej.Base.TextUtils
Namespace: Wisej.Base
Assembly: Wisej.Framework (3.1.0.0)
Provides utility methods to measure, encode, and extract mnemonics from text.
C#
VB.NET
public class TextUtils
Public Class TextUtils

Fields

Name
Type
Description
ConvertToString
Pluggable method used to convert user input to a string. [Since 3.0.10]
MeasureString
Pluggable method used to measure strings.

Methods

EscapeText(text, allowHtml)

Escapes special characters in the specified string.
Parameter
Type
Description
text
String
The text to escape.
allowHtml
Boolean
Indicates that HTML tags should not be escaped. The default is false.
Returns: String. The escaped string. Null if the specified string was null, or empty if it was empty.

EscapeText(text, allowHtml, useMnemonic, translateNewLines)

Removes the ampersand from the text and encodes HTML characters if necessary.
Parameter
Type
Description
text
String
The text to convert.
allowHtml
Boolean
Whether to encode HTML characters.
useMnemonic
Boolean
Whether to convert the first mnemonic to an underlined character.
translateNewLines
Boolean
Whether to convert newlines (CRLF) to . The conversion is performed only when allowHtml is false, or, if allowHtml is true and the text doesn't contain any HTML.
Returns: String. The escaped string. Null if the specified string was null, or empty if it was empty.

GetMnemonic(text)

Returns the first character that is preceded by an ampersand (&).
Parameter
Type
Description
text
String
The string from which to extract the mnemonic character.
Returns: String.

MeasureText(text, font)

Returns the size of the specified text when rendered with the specified font.
Parameter
Type
Description
text
String
The text to measure.
font
Font
The Font to apply to the measured text.
Returns: Size. The computed Size of the specified text.

MeasureText(text, font, format)

Returns the size of the specified text when rendered with the specified font.
Parameter
Type
Description
text
String
The text to measure.
font
Font
The Font to apply to the measured text.
format
Formatting information.
Returns: Size. The computed Size of the specified text.

MeasureText(text, font, layoutArea)

Returns the size of the specified text when rendered with the specified font.
Parameter
Type
Description
text
String
The text to measure.
font
Font
The Font to apply to the measured text.
layoutArea
Size
The Size to use as bounding rectangle for the text.
Returns: Size.

MeasureText(text, font, layoutArea, format)

Returns the size of the specified text when rendered with the specified font.
Parameter
Type
Description
text
String
The text to measure.
font
Font
The Font to apply to the measured text.
layoutArea
Size
The Size to use as bounding rectangle for the text.
format
Formatting information.
Returns: Size.

MeasureText(text, allowHtml, font, callback)

Returns the size of the specified text when rendered with the specified font.
Parameter
Type
Description
text
String
The text to measure.
allowHtml
Boolean
The text to measure may contain HTML tags.
font
Font
The Font to apply to the measured text.
callback
Result callback method, invoked when the client has finished measuring the text.

MeasureText(text, allowHtml, font, width, callback)

Returns the size of the specified text when rendered with the specified font.
Parameter
Type
Description
text
String
The text to measure.
allowHtml
Boolean
The text to measure may contain HTML tags.
font
Font
The Font to apply to the measured text.
width
Int32
The width to use as bounding rectangle for the text.
callback
Result callback method, invoked when the client has finished measuring the text.

MeasureTextAsync(text, allowHtml, font, width)

Asynchronously returns the size of the specified text when rendered with the specified font. The measurement is performed on the browser. Returns an awaitable Task that contains the measured size.
Parameter
Type
Description
text
String
The text to measure.
allowHtml
Boolean
The text to measure may contain HTML tags.
font
Font
The Font to apply to the measured text.
width
Int32
The optional width to use as bounding rectangle for the text.
Returns: Task<Size>. An awaitable Task that represents the asynchronous operation.