Chromium Code Reviews| Index: sdk/lib/convert/utf.dart |
| diff --git a/sdk/lib/convert/utf.dart b/sdk/lib/convert/utf.dart |
| index 80f7a7837f15ece8586f67385f46b0d3b5f3fd03..5a6cfe6ade59c9c2ffc7248eec783c9694f04492 100644 |
| --- a/sdk/lib/convert/utf.dart |
| +++ b/sdk/lib/convert/utf.dart |
| @@ -455,7 +455,14 @@ class _Utf8Decoder { |
| while (i < endIndex) { |
| int unit = codeUnits[i++]; |
| - if (unit <= _ONE_BYTE_LIMIT) { |
| + if (unit < 0) { |
|
Lasse Reichstein Nielsen
2013/08/22 06:10:42
Would it be cheaper/faster to do:
if ((unit & ~0
floitsch
2013/08/22 15:40:25
Rapidly tried it, but somehow introduced a bug. No
|
| + // TODO(floitsch): should this be unit <= 0 ? |
|
Lasse Reichstein Nielsen
2013/08/22 06:10:42
No, zero is a valid UTF-8 code unit encoding the U
floitsch
2013/08/22 15:40:25
Done.
|
| + if (!_allowMalformed) { |
| + throw new FormatException( |
| + "Negative UTF-8 code unit: -0x${(-unit).toRadixString(16)}"); |
| + } |
| + _stringSink.writeCharCode(_REPLACEMENT_CHARACTER); |
| + } else if (unit <= _ONE_BYTE_LIMIT) { |
| _isFirstCharacter = false; |
| _stringSink.writeCharCode(unit); |
| } else { |