unicode.dart 3.03 KB
Newer Older
Ian Hickson's avatar
Ian Hickson committed
1
// Copyright 2014 The Flutter Authors. All rights reserved.
Ian Hickson's avatar
Ian Hickson committed
2 3 4 5 6 7 8 9 10 11 12 13
// 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 {
14
  // This class is not meant to be instantiated or extended; this constructor
15
  // prevents instantiation and extension.
Ian Hickson's avatar
Ian Hickson committed
16
  Unicode._();
17
  /// `U+202A LEFT-TO-RIGHT EMBEDDING`
Ian Hickson's avatar
Ian Hickson committed
18 19 20 21 22 23
  ///
  /// Treat the following text as embedded left-to-right.
  ///
  /// Use [PDF] to end the embedding.
  static const String LRE = '\u202A';

24
  /// `U+202B RIGHT-TO-LEFT EMBEDDING`
Ian Hickson's avatar
Ian Hickson committed
25 26 27 28 29 30
  ///
  /// Treat the following text as embedded right-to-left.
  ///
  /// Use [PDF] to end the embedding.
  static const String RLE = '\u202B';

31
  /// `U+202C POP DIRECTIONAL FORMATTING`
Ian Hickson's avatar
Ian Hickson committed
32 33 34 35
  ///
  /// End the scope of the last [LRE], [RLE], [RLO], or [LRO].
  static const String PDF = '\u202C';

36
  /// `U+202A LEFT-TO-RIGHT OVERRIDE`
Ian Hickson's avatar
Ian Hickson committed
37 38 39 40 41 42 43 44
  ///
  /// 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';

45
  /// `U+202B RIGHT-TO-LEFT OVERRIDE`
Ian Hickson's avatar
Ian Hickson committed
46 47 48 49 50 51 52 53
  ///
  /// 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';

54
  /// `U+2066 LEFT-TO-RIGHT ISOLATE`
Ian Hickson's avatar
Ian Hickson committed
55 56 57 58 59 60
  ///
  /// Treat the following text as isolated and left-to-right.
  ///
  /// Use [PDI] to end the isolated scope.
  static const String LRI = '\u2066';

61
  /// `U+2067 RIGHT-TO-LEFT ISOLATE`
Ian Hickson's avatar
Ian Hickson committed
62 63 64 65 66 67
  ///
  /// Treat the following text as isolated and right-to-left.
  ///
  /// Use [PDI] to end the isolated scope.
  static const String RLI = '\u2067';

68
  /// `U+2068 FIRST STRONG ISOLATE`
Ian Hickson's avatar
Ian Hickson committed
69 70 71 72
  ///
  /// Treat the following text as isolated and in the direction of its first
  /// strong directional character that is not inside a nested isolate.
  ///
73
  /// This essentially "auto-detects" the directionality of the text. It is not
Ian Hickson's avatar
Ian Hickson committed
74 75 76 77 78 79 80
  /// 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';

81
  /// `U+2069 POP DIRECTIONAL ISOLATE`
Ian Hickson's avatar
Ian Hickson committed
82 83 84 85
  ///
  /// End the scope of the last [LRI], [RLI], or [FSI].
  static const String PDI = '\u2069';

86
  /// `U+200E LEFT-TO-RIGHT MARK`
Ian Hickson's avatar
Ian Hickson committed
87 88 89 90
  ///
  /// Left-to-right zero-width character.
  static const String LRM = '\u200E';

91
  /// `U+200F RIGHT-TO-LEFT MARK`
Ian Hickson's avatar
Ian Hickson committed
92 93 94 95
  ///
  /// Right-to-left zero-width non-Arabic character.
  static const String RLM = '\u200F';

96
  /// `U+061C ARABIC LETTER MARK`
Ian Hickson's avatar
Ian Hickson committed
97 98 99 100
  ///
  /// Right-to-left zero-width Arabic character.
  static const String ALM = '\u061C';
}