unicodeWrap

open fun unicodeWrap(str: String, heuristic: TextDirectionHeuristicCompat, isolate: Boolean): String(source)

Formats a string of given directionality for use in plain-text output of the context directionality, so an opposite-directionality string is neither garbled nor garbles its surroundings. This makes use of Unicode bidi formatting characters.

The algorithm: In case the given directionality doesn't match the context directionality, wraps the string with Unicode bidi formatting characters: RLE+str+PDF for RTL text, or LRE+str+PDF for LTR text.

If isolate, directionally isolates the string so that it does not garble its surroundings. Currently, this is done by "resetting" the directionality after the string by appending a trailing Unicode bidi mark matching the context directionality (LRM or RLM) when either the overall directionality or the exit directionality of the string is opposite to that of the context. Unless the formatter was built using stereoReset with a false argument, also prepends a Unicode bidi mark matching the context directionality when either the overall directionality or the entry directionality of the string is opposite to that of the context. Note that as opposed to the overall directionality, the entry and exit directionalities are determined from the string itself.

Does *not* do HTML-escaping.

Return

Input string after applying the above processing. null if str is null.

Parameters

str

The input string.

heuristic

The algorithm to be used to estimate the string's overall direction.

isolate

Whether to directionally isolate the string to prevent it from garbling the content around it


Operates like unicodeWrap, but takes a CharSequence instead of a string

Return

Input CharSequence after applying the above processing. null if str is null.

Parameters

str

The input CharSequence.

heuristic

The algorithm to be used to estimate the CharSequence's overall direction. See androidx.core.text.TextDirectionHeuristicsCompat for pre-defined heuristics.

isolate

Whether to directionally isolate the CharSequence to prevent it from garbling the content around it


Operates like unicodeWrap, but assumes isolate is true.

Return

Input string after applying the above processing.

Parameters

str

The input string.

heuristic

The algorithm to be used to estimate the string's overall direction.


Operates like unicodeWrap, but assumes isolate is true.

Return

Input CharSequence after applying the above processing.

Parameters

str

The input CharSequence.

heuristic

The algorithm to be used to estimate the CharSequence's overall direction. See androidx.core.text.TextDirectionHeuristicsCompat for pre-defined heuristics.


open fun unicodeWrap(str: String, isolate: Boolean): String(source)

Operates like unicodeWrap, but uses the formatter's default direction estimation algorithm.

Return

Input string after applying the above processing.

Parameters

str

The input string.

isolate

Whether to directionally isolate the string to prevent it from garbling the content around it


Operates like unicodeWrap, but uses the formatter's default direction estimation algorithm.

Return

Input CharSequence after applying the above processing.

Parameters

str

The input CharSequence.

isolate

Whether to directionally isolate the CharSequence to prevent it from garbling the content around it


open fun unicodeWrap(str: String): String(source)

Operates like unicodeWrap, but uses the formatter's default direction estimation algorithm and assumes isolate is true.

Return

Input string after applying the above processing.

Parameters

str

The input string.


Operates like unicodeWrap, but uses the formatter's default direction estimation algorithm and assumes isolate is true.

Return

Input CharSequence after applying the above processing.

Parameters

str

The input CharSequence.