unicode.dart 2.88 KB
Newer Older
Ian Hickson's avatar
Ian Hickson committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

/// Constants for useful Unicode characters.
///
/// Currently, these characters are all related to bidirectional text.
///
/// See also:
///
///  * <http://unicode.org/reports/tr9/>, which describes the Unicode
///    bidirectional text algorithm.
class Unicode {
  Unicode._();
  /// U+202A LEFT-TO-RIGHT EMBEDDING
  ///
  /// Treat the following text as embedded left-to-right.
  ///
  /// Use [PDF] to end the embedding.
  static const String LRE = '\u202A';

  /// U+202B RIGHT-TO-LEFT EMBEDDING
  ///
  /// Treat the following text as embedded right-to-left.
  ///
  /// Use [PDF] to end the embedding.
  static const String RLE = '\u202B';

  /// U+202C POP DIRECTIONAL FORMATTING
  ///
  /// End the scope of the last [LRE], [RLE], [RLO], or [LRO].
  static const String PDF = '\u202C';

  /// U+202A LEFT-TO-RIGHT OVERRIDE
  ///
  /// Force following characters to be treated as strong left-to-right characters.
  ///
  /// For example, this causes Hebrew text to render backwards.
  ///
  /// Use [PDF] to end the override.
  static const String LRO = '\u202D';

  /// U+202B RIGHT-TO-LEFT OVERRIDE
  ///
  /// Force following characters to be treated as strong right-to-left characters.
  ///
  /// For example, this causes English text to render backwards.
  ///
  /// Use [PDF] to end the override.
  static const String RLO = '\u202E';

  /// U+2066 LEFT-TO-RIGHT ISOLATE
  ///
  /// Treat the following text as isolated and left-to-right.
  ///
  /// Use [PDI] to end the isolated scope.
  static const String LRI = '\u2066';

  /// U+2067 RIGHT-TO-LEFT ISOLATE
  ///
  /// Treat the following text as isolated and right-to-left.
  ///
  /// Use [PDI] to end the isolated scope.
  static const String RLI = '\u2067';

  /// U+2068 FIRST STRONG ISOLATE
  ///
  /// Treat the following text as isolated and in the direction of its first
  /// strong directional character that is not inside a nested isolate.
  ///
  /// This essentially "autodetects" the directionality of the text. It is not
  /// 100% reliable. For example, Arabic text that starts with an English quote
  /// will be detected as LTR, not RTL, which will lead to the text being in a
  /// weird order.
  ///
  /// Use [PDI] to end the isolated scope.
  static const String FSI = '\u2068';

  /// U+2069 POP DIRECTIONAL ISOLATE
  ///
  /// End the scope of the last [LRI], [RLI], or [FSI].
  static const String PDI = '\u2069';

  /// U+200E LEFT-TO-RIGHT MARK
  ///
  /// Left-to-right zero-width character.
  static const String LRM = '\u200E';

  /// U+200F RIGHT-TO-LEFT MARK
  ///
  /// Right-to-left zero-width non-Arabic character.
  static const String RLM = '\u200F';

  /// U+061C ARABIC LETTER MARK
  ///
  /// Right-to-left zero-width Arabic character.
  static const String ALM = '\u061C';
}