wrapWithControls static method

String wrapWithControls(
  1. String text
)

Applies bidirectional control characters to ensure correct display.

This is useful when you need to ensure text is displayed correctly... ....in environments that might not fully implement the Unicode Bidirectional Algorithm.

Implementation

static String wrapWithControls(String text) {
  if (!containsRtl(text)) {
    return text;
  }

  if (isRtl(text)) {
    return '\u202B' + text + '\u202C';
  } else {
    return '\u202A' + text + '\u202C';
  }
}