* Quick check for RTL characters (Hebrew, Arabic, and related scripts). * Avoids running the full bidi algorithm on pure-LTR text.
(text: string)
| 129 | * Avoids running the full bidi algorithm on pure-LTR text. |
| 130 | */ |
| 131 | function hasRTLCharacters(text: string): boolean { |
| 132 | // Hebrew: U+0590-U+05FF, U+FB1D-U+FB4F |
| 133 | // Arabic: U+0600-U+06FF, U+0750-U+077F, U+08A0-U+08FF, U+FB50-U+FDFF, U+FE70-U+FEFF |
| 134 | // Thaana: U+0780-U+07BF |
| 135 | // Syriac: U+0700-U+074F |
| 136 | return /[\u0590-\u05FF\uFB1D-\uFB4F\u0600-\u06FF\u0750-\u077F\u08A0-\u08FF\uFB50-\uFDFF\uFE70-\uFEFF\u0780-\u07BF\u0700-\u074F]/u.test( |
| 137 | text, |
| 138 | ) |
| 139 | } |
| 140 |