i2 Notebook SDK
Search results for

    Show/hide table of contents

    Home > @i2analyze/notebook-sdk > data > IFormatter > wrapForBidi

    data.IFormatter.wrapForBidi() method

    Wraps an input string in invisible Unicode Control Characters (LRE, RLE, PDF) to provide correct bidirectional behavior for the specified text direction.

    Signature:

    wrapForBidi(value: string, mode: 'raw' | 'wrapParens' | 'wrapSingleQuotes' | 'wrapDoubleQuotes', forceTextDirection?: BaseTextDirection): string;
    

    Introduced: version 1.0

    Parameters

    Parameter Type Description
    value string The string to wrap.
    mode 'raw' | 'wrapParens' | 'wrapSingleQuotes' | 'wrapDoubleQuotes' An indication of whether to put the string between parentheses, single quotes, or double quotes before bidi wrapping takes place.
    forceTextDirection BaseTextDirection (Optional) The text direction to use, overriding the application-wide, user-configured direction.

    Returns:

    string

    A string wrapped as specified by mode and forceTextDirection.

    Remarks

    For a plug-in that deals with bidirectional text, it is sometimes necessary to provide assistance to the browser so that it keeps text together correctly. This method provides an easy way to wrap strings with appropriate control characters, based on the application-wide, user-configurable base text direction and the text itself.

    For example, the English text "(optional)" might get rendered as ")optional)" in a right-to-left page, because of the way browsers treat 'weak' Unicode characters such as parentheses. Wrapping the text with control characters, as in "LRE(optional)PDF", tells the browser to treat the whole string as a single piece of left-to-right text.

    Anything that should be treated as a single run of text must be passed directly to this method. Do not, for example, call the method to wrap text and then put parentheses around the text - the parentheses must be wrapped too.

    You can direct this method to put parentheses or quotes around your string before wrapping it with Unicode Control Characters by specifying different values for the mode parameter. If you need to use other characters, add them manually and then use the raw wrapping mode.

    In this article
    Back to top © N. Harris Computer Corporation