Chromium Code Reviews| Index: sdk/lib/convert/utf.dart |
| diff --git a/sdk/lib/convert/utf.dart b/sdk/lib/convert/utf.dart |
| index 6abaa0519b959200fe49ec33d7df190bd23fc352..b350f7d5efab7583a474f7a7da2858b8741a2736 100644 |
| --- a/sdk/lib/convert/utf.dart |
| +++ b/sdk/lib/convert/utf.dart |
| @@ -7,6 +7,9 @@ part of dart.convert; |
| /** The Unicode Replacement character `U+FFFD` (�). */ |
| const UNICODE_REPLACEMENT_CHARACTER_RUNE = 0xFFFD; |
| +/** The Unicode Byte Order Marker (BOM) character `U+FEFF`. */ |
| +const UNICODE_BOM_CHARACTER_RUNE = 0xFEFF; |
| + |
| /** |
| * An instance of the default implementation of the [Utf8Codec]. |
| * |
| @@ -48,6 +51,9 @@ class Utf8Codec extends Encoding { |
| * Decodes the UTF-8 [codeUnits] (a list of unsigned 8-bit integers) to the |
| * corresponding string. |
| * |
| + * If the [codeUnits] start with a leading [UNICODE_BOM_CHARACTER_RUNE] this |
|
Anders Johnsen
2013/10/01 11:32:29
Is this really happening? I don't see any usage of
floitsch
2013/10/01 11:37:42
There was a private copy of it. I removed that one
|
| + * character is discarded. |
| + * |
| * If [allowMalformed] is `true` the decoder replaces invalid (or |
| * unterminated) character sequences with the Unicode Replacement character |
| * `U+FFFD` (�). Otherwise it throws a [FormatException]. |
| @@ -303,6 +309,9 @@ class Utf8Decoder extends Converter<List<int>, String> { |
| /** |
| * Converts the UTF-8 [codeUnits] (a list of unsigned 8-bit integers) to the |
| * corresponding string. |
| + * |
| + * If the [codeUnits] start with a leading [UNICODE_BOM_CHARACTER_RUNE] this |
| + * character is discarded. |
| */ |
| String convert(List<int> codeUnits) { |
| StringBuffer buffer = new StringBuffer(); |
| @@ -356,7 +365,7 @@ bool _isLeadSurrogate(int codeUnit) => |
| bool _isTailSurrogate(int codeUnit) => |
| (codeUnit & _SURROGATE_TAG_MASK) == _TAIL_SURROGATE_MIN; |
| int _combineSurrogatePair(int lead, int tail) => |
| - 0x10000 | ((lead & _SURROGATE_VALUE_MASK) << 10) |
| + 0x10000 + ((lead & _SURROGATE_VALUE_MASK) << 10) |
| | (tail & _SURROGATE_VALUE_MASK); |