| Index: runtime/lib/string_patch.dart
|
| diff --git a/runtime/lib/string_patch.dart b/runtime/lib/string_patch.dart
|
| index 3fb0f721ee8ba398e5d9b24246fe188ac7b2aa04..f728341268f04bff2c54afdf027a76127e8bea87 100644
|
| --- a/runtime/lib/string_patch.dart
|
| +++ b/runtime/lib/string_patch.dart
|
| @@ -200,12 +200,48 @@ class _StringBase {
|
| native "StringBase_substringUnchecked";
|
|
|
| // Checks for one-byte whitespaces only.
|
| - // TODO(srdjan): Investigate if 0x85 (NEL) and 0xA0 (NBSP) are valid
|
| - // whitespaces for one byte strings.
|
| static bool _isOneByteWhitespace(int codePoint) {
|
| return
|
| (codePoint == 32) || // Space.
|
| - ((9 <= codePoint) && (codePoint <= 13)); // CR, LF, TAB, etc.
|
| + ((9 <= codePoint) && (codePoint <= 13)) || // CR, LF, TAB, etc.
|
| + (codePoint == 0x85) || // NEL
|
| + (codePoint == 0xA0); // NBSP
|
| + }
|
| +
|
| + // Characters in the Zl category:
|
| + // U+0020 SPACE
|
| + // U+00A0 NO-BREAK SPACE
|
| + // U+1680 OGHAM SPACE MARK
|
| + // U+180E MONGOLIAN VOWEL SEPARATOR
|
| + // U+2000 EN QUAD
|
| + // U+2001 EM QUAD
|
| + // U+2002 EN SPACE
|
| + // U+2003 EM SPACE
|
| + // U+2004 THREE-PER-EM SPACE
|
| + // U+2005 FOUR-PER-EM SPACE
|
| + // U+2006 SIX-PER-EM SPACE
|
| + // U+2007 FIGURE SPACE
|
| + // U+2008 PUNCTUATION SPACE
|
| + // U+2009 THIN SPACE
|
| + // U+200A HAIR SPACE
|
| + // U+202F NARROW NO-BREAK SPACE
|
| + // U+205F MEDIUM MATHEMATICAL SPACE
|
| + // U+3000 IDEOGRAPHIC SPACE
|
| + //
|
| + // Characters in the Zl category: 0x2028
|
| + // Characters in the Zp category: 0x2029
|
| + // BOM: 0xFEFF
|
| + static bool _isTwoByteWhitespace(int codePoint) {
|
| + if (codePoint < 256) return _isOneByteWhitespace(codePoint);
|
| + return (codePoint == 0x1680) ||
|
| + (codePoint == 0x180E) ||
|
| + ((0x2000 <= codePoint) && (codePoint <= 0x200A)) ||
|
| + (codePoint == 0x202F) ||
|
| + (codePoint == 0x205F) ||
|
| + (codePoint == 0x3000) ||
|
| + (codePoint == 0x2028) ||
|
| + (codePoint == 0x2029) ||
|
| + (codePoint == 0xFEFF);
|
| }
|
|
|
| String trim() {
|
| @@ -573,8 +609,7 @@ class _TwoByteString extends _StringBase implements String {
|
| }
|
|
|
| bool _isWhitespace(int codePoint) {
|
| - // For now we only check for one byte white space characters.
|
| - return _StringBase._isOneByteWhitespace(codePoint);
|
| + return _StringBase._isTwoByteWhitespace(codePoint);
|
| }
|
| }
|
|
|
| @@ -598,8 +633,7 @@ class _ExternalTwoByteString extends _StringBase implements String {
|
| }
|
|
|
| bool _isWhitespace(int codePoint) {
|
| - // For now we only check for one byte white space characters.
|
| - return _StringBase._isOneByteWhitespace(codePoint);
|
| + return _StringBase._isTwoByteWhitespace(codePoint);
|
| }
|
| }
|
|
|
|
|