Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(246)

Side by Side Diff: pkg/intl/lib/bidi_utils.dart

Issue 12262030: Stop using deprecated charCodeAt in Intl (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | pkg/intl/lib/number_format.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 if (total == 0) { 346 if (total == 0) {
347 return hasWeaklyLtr ? TextDirection.LTR : TextDirection.UNKNOWN; 347 return hasWeaklyLtr ? TextDirection.LTR : TextDirection.UNKNOWN;
348 } else if (rtlCount > _RTL_DETECTION_THRESHOLD * total) { 348 } else if (rtlCount > _RTL_DETECTION_THRESHOLD * total) {
349 return TextDirection.RTL; 349 return TextDirection.RTL;
350 } else { 350 } else {
351 return TextDirection.LTR; 351 return TextDirection.LTR;
352 } 352 }
353 } 353 }
354 354
355 /** 355 /**
356 * Find the first index in [str] of the first closing parenthesis that does
357 * not match an opening parenthesis.
358 */
359 static int _unmatchedParenIndex(String str) {
360 int sum = 0;
361 int index = 0;
362 while (sum >= 0 || index > str.length) {
363 int char = str.charCodeAt(index);
364 if (char == '('.charCodeAt(0)) sum++;
365 else if (char == ')'.charCodeAt(0)) sum--;
366 index++;
367 }
368 return index;
369 }
370
371 /**
372 * Replace the double and single quote directly after a Hebrew character in 356 * Replace the double and single quote directly after a Hebrew character in
373 * [str] with GERESH and GERSHAYIM. This is most likely the user's intention. 357 * [str] with GERESH and GERSHAYIM. This is most likely the user's intention.
374 */ 358 */
375 static String normalizeHebrewQuote(String str) { 359 static String normalizeHebrewQuote(String str) {
376 StringBuffer buf = new StringBuffer(); 360 StringBuffer buf = new StringBuffer();
377 if (str.length > 0) { 361 if (str.length > 0) {
378 buf.add(str.substring(0, 1)); 362 buf.add(str.substring(0, 1));
379 } 363 }
380 // Start at 1 because we're looking for the patterns [\u0591-\u05f2])" or 364 // Start at 1 because we're looking for the patterns [\u0591-\u05f2])" or
381 // [\u0591-\u05f2]'. 365 // [\u0591-\u05f2]'.
(...skipping 13 matching lines...) Expand all
395 379
396 /** 380 /**
397 * Check the estimated directionality of [str], return true if the piece of 381 * Check the estimated directionality of [str], return true if the piece of
398 * text should be laid out in RTL direction. If [isHtml] is true, the string 382 * text should be laid out in RTL direction. If [isHtml] is true, the string
399 * is HTML or HTML-escaped. 383 * is HTML or HTML-escaped.
400 */ 384 */
401 static bool detectRtlDirectionality(String str, {bool isHtml: false}) { 385 static bool detectRtlDirectionality(String str, {bool isHtml: false}) {
402 return estimateDirectionOfText(str, isHtml: isHtml) == TextDirection.RTL; 386 return estimateDirectionOfText(str, isHtml: isHtml) == TextDirection.RTL;
403 } 387 }
404 } 388 }
OLDNEW
« no previous file with comments | « no previous file | pkg/intl/lib/number_format.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698