Index: runtime/lib/string_patch.dart |
diff --git a/runtime/lib/string_patch.dart b/runtime/lib/string_patch.dart |
index e9f575940db25bc174bee17c4c43497df754ad20..89dce3e56c87fd048a806f989cc01ae4952a8d2c 100644 |
--- a/runtime/lib/string_patch.dart |
+++ b/runtime/lib/string_patch.dart |
@@ -511,12 +511,11 @@ class _OneByteString extends _StringBase implements String { |
int get hashCode native "String_getHashCode"; |
// Checks for one-byte whitespaces only. |
- // TODO(srdjan): Investigate if 0x85 (NEL) and 0xA0 (NBSP) are valid |
- // whitespaces for one byte strings. |
bool _isWhitespace(int codePoint) { |
return |
(codePoint == 32) || // Space. |
- ((9 <= codePoint) && (codePoint <= 13)); // CR, LF, TAB, etc. |
+ ((9 <= codePoint) && (codePoint <= 13)) || // CR, LF, TAB, etc. |
+ (codePoint == 0xA0); // NBSP. |
} |
String _substringUncheckedNative(int startIndex, int endIndex) |
@@ -568,13 +567,44 @@ class _TwoByteString extends _StringBase implements String { |
"_TwoByteString can only be allocated by the VM"); |
} |
- // Checks for one-byte whitespaces only. |
- // TODO(srdjan): Investigate if 0x85 (NEL) and 0xA0 (NBSP) are valid |
- // whitespaces. Add checking for multi-byte whitespace codepoints. |
+ // 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 |
bool _isWhitespace(int codePoint) { |
return |
- (codePoint == 32) || // Space. |
- ((9 <= codePoint) && (codePoint <= 13)); // CR, LF, TAB, etc. |
+ (codePoint == 32) || // Space. |
+ ((9 <= codePoint) && (codePoint <= 13)) || // CR, LF, TAB, etc. |
+ (codePoint == 0xA0) || // NBSP. |
+ // Characters in the Zs category: |
+ (codePoint == 0x1680) || |
+ (codePoint == 0x180E) || |
+ ((0x2000 <= codePoint) && (codePoint <= 0x200A)) || |
+ (codePoint == 0x202F) || |
+ (codePoint == 0x205F) || |
+ (codePoint == 0x3000) || |
+ (codePoint == 0x2028) || |
+ (codePoint == 0x2029) || |
+ (codePoint == 0xFEFF); |
} |
} |
@@ -585,13 +615,21 @@ class _FourByteString extends _StringBase implements String { |
"_FourByteString can only be allocated by the VM"); |
} |
- // Checks for one-byte whitespaces only. |
- // TODO(srdjan): Investigate if 0x85 (NEL) and 0xA0 (NBSP) are valid |
- // whitespaces. Add checking for multi-byte whitespace codepoints. |
bool _isWhitespace(int codePoint) { |
return |
- (codePoint == 32) || // Space. |
- ((9 <= codePoint) && (codePoint <= 13)); // CR, LF, TAB, etc. |
+ (codePoint == 32) || // Space. |
+ ((9 <= codePoint) && (codePoint <= 13)) || // CR, LF, TAB, etc. |
+ (codePoint == 0xA0) || // NBSP. |
+ // Characters in the Zs category: |
+ (codePoint == 0x1680) || |
+ (codePoint == 0x180E) || |
+ ((0x2000 <= codePoint) && (codePoint <= 0x200A)) || |
+ (codePoint == 0x202F) || |
+ (codePoint == 0x205F) || |
+ (codePoint == 0x3000) || |
+ (codePoint == 0x2028) || |
+ (codePoint == 0x2029) || |
+ (codePoint == 0xFEFF); |
} |
} |
@@ -603,12 +641,11 @@ class _ExternalOneByteString extends _StringBase implements String { |
} |
// Checks for one-byte whitespaces only. |
- // TODO(srdjan): Investigate if 0x85 (NEL) and 0xA0 (NBSP) are valid |
- // whitespaces for one byte strings. |
bool _isWhitespace(int codePoint) { |
return |
(codePoint == 32) || // Space. |
- ((9 <= codePoint) && (codePoint <= 13)); // CR, LF, TAB, etc. |
+ ((9 <= codePoint) && (codePoint <= 13)) || // CR, LF, TAB, etc. |
+ (codePoint == 0xA0); // NBSP. |
} |
} |
@@ -619,13 +656,21 @@ class _ExternalTwoByteString extends _StringBase implements String { |
"_ExternalTwoByteString can only be allocated by the VM"); |
} |
- // Checks for one-byte whitespaces only. |
- // TODO(srdjan): Investigate if 0x85 (NEL) and 0xA0 (NBSP) are valid |
- // whitespaces. Add checking for multi-byte whitespace codepoints. |
bool _isWhitespace(int codePoint) { |
return |
- (codePoint == 32) || // Space. |
- ((9 <= codePoint) && (codePoint <= 13)); // CR, LF, TAB, etc. |
+ (codePoint == 32) || // Space. |
+ ((9 <= codePoint) && (codePoint <= 13)) || // CR, LF, TAB, etc. |
+ (codePoint == 0xA0) || // NBSP. |
+ // Characters in the Zs category: |
+ (codePoint == 0x1680) || |
+ (codePoint == 0x180E) || |
+ ((0x2000 <= codePoint) && (codePoint <= 0x200A)) || |
+ (codePoint == 0x202F) || |
+ (codePoint == 0x205F) || |
+ (codePoint == 0x3000) || |
+ (codePoint == 0x2028) || |
+ (codePoint == 0x2029) || |
+ (codePoint == 0xFEFF); |
} |
} |