| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 part of intl; | 5 part of intl; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * Bidi stands for Bi-directional text. | 8 * Bidi stands for Bi-directional text. |
| 9 * According to http://en.wikipedia.org/wiki/Bi-directional_text: | 9 * According to http://en.wikipedia.org/wiki/Bi-directional_text: |
| 10 * Bi-directional text is text containing text in both text directionalities, | 10 * Bi-directional text is text containing text in both text directionalities, |
| (...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 356 // Start at 1 because we're looking for the patterns [\u0591-\u05f2])" or | 356 // Start at 1 because we're looking for the patterns [\u0591-\u05f2])" or |
| 357 // [\u0591-\u05f2]'. | 357 // [\u0591-\u05f2]'. |
| 358 for (int i = 1; i < str.length; i++) { | 358 for (int i = 1; i < str.length; i++) { |
| 359 if (str.substring(i, i+1) == '"' | 359 if (str.substring(i, i+1) == '"' |
| 360 && new RegExp('[\u0591-\u05f2]').hasMatch(str.substring(i-1, i))) { | 360 && new RegExp('[\u0591-\u05f2]').hasMatch(str.substring(i-1, i))) { |
| 361 buf.write('\u05f4'); | 361 buf.write('\u05f4'); |
| 362 } else if (str.substring(i, i+1) == "'" | 362 } else if (str.substring(i, i+1) == "'" |
| 363 && new RegExp('[\u0591-\u05f2]').hasMatch(str.substring(i-1, i))) { | 363 && new RegExp('[\u0591-\u05f2]').hasMatch(str.substring(i-1, i))) { |
| 364 buf.write('\u05f3'); | 364 buf.write('\u05f3'); |
| 365 } else { | 365 } else { |
| 366 buf.write(str.substring(i, i+1)); | 366 buf.write(str.substring(i, i + 1)); |
| 367 } | 367 } |
| 368 } | 368 } |
| 369 return buf.toString(); | 369 return buf.toString(); |
| 370 } | 370 } |
| 371 | 371 |
| 372 /** | 372 /** |
| 373 * Check the estimated directionality of [str], return true if the piece of | 373 * Check the estimated directionality of [str], return true if the piece of |
| 374 * text should be laid out in RTL direction. If [isHtml] is true, the string | 374 * text should be laid out in RTL direction. If [isHtml] is true, the string |
| 375 * is HTML or HTML-escaped. | 375 * is HTML or HTML-escaped. |
| 376 */ | 376 */ |
| 377 static bool detectRtlDirectionality(String str, {bool isHtml: false}) => | 377 static bool detectRtlDirectionality(String str, {bool isHtml: false}) => |
| 378 estimateDirectionOfText(str, isHtml: isHtml) == TextDirection.RTL; | 378 estimateDirectionOfText(str, isHtml: isHtml) == TextDirection.RTL; |
| 379 } | 379 } |
| OLD | NEW |