| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 dart.convert; | 5 part of dart.convert; |
| 6 | 6 |
| 7 /** The Unicode Replacement character `U+FFFD` (�). */ | 7 /** The Unicode Replacement character `U+FFFD` (�). */ |
| 8 const int UNICODE_REPLACEMENT_CHARACTER_RUNE = 0xFFFD; | 8 const int UNICODE_REPLACEMENT_CHARACTER_RUNE = 0xFFFD; |
| 9 | 9 |
| 10 /** The Unicode Byte Order Marker (BOM) character `U+FEFF`. */ | 10 /** The Unicode Byte Order Marker (BOM) character `U+FEFF`. */ |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 */ | 44 */ |
| 45 const Utf8Codec({ bool allowMalformed: false }) | 45 const Utf8Codec({ bool allowMalformed: false }) |
| 46 : _allowMalformed = allowMalformed; | 46 : _allowMalformed = allowMalformed; |
| 47 | 47 |
| 48 String get name => "utf-8"; | 48 String get name => "utf-8"; |
| 49 | 49 |
| 50 /** | 50 /** |
| 51 * Decodes the UTF-8 [codeUnits] (a list of unsigned 8-bit integers) to the | 51 * Decodes the UTF-8 [codeUnits] (a list of unsigned 8-bit integers) to the |
| 52 * corresponding string. | 52 * corresponding string. |
| 53 * | 53 * |
| 54 * If the [codeUnits] start with a leading [UNICODE_BOM_CHARACTER_RUNE] this | 54 * If the [codeUnits] start with the encoding of a |
| 55 * character is discarded. | 55 * [UNICODE_BOM_CHARACTER_RUNE], that character is discarded. |
| 56 * | 56 * |
| 57 * If [allowMalformed] is `true` the decoder replaces invalid (or | 57 * If [allowMalformed] is `true` the decoder replaces invalid (or |
| 58 * unterminated) character sequences with the Unicode Replacement character | 58 * unterminated) character sequences with the Unicode Replacement character |
| 59 * `U+FFFD` (�). Otherwise it throws a [FormatException]. | 59 * `U+FFFD` (�). Otherwise it throws a [FormatException]. |
| 60 * | 60 * |
| 61 * If [allowMalformed] is not given, it defaults to the `allowMalformed` that | 61 * If [allowMalformed] is not given, it defaults to the `allowMalformed` that |
| 62 * was used to instantiate `this`. | 62 * was used to instantiate `this`. |
| 63 */ | 63 */ |
| 64 String decode(List<int> codeUnits, { bool allowMalformed }) { | 64 String decode(List<int> codeUnits, { bool allowMalformed }) { |
| 65 if (allowMalformed == null) allowMalformed = _allowMalformed; | 65 if (allowMalformed == null) allowMalformed = _allowMalformed; |
| (...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 574 } | 574 } |
| 575 break loop; | 575 break loop; |
| 576 } | 576 } |
| 577 if (expectedUnits > 0) { | 577 if (expectedUnits > 0) { |
| 578 _value = value; | 578 _value = value; |
| 579 _expectedUnits = expectedUnits; | 579 _expectedUnits = expectedUnits; |
| 580 _extraUnits = extraUnits; | 580 _extraUnits = extraUnits; |
| 581 } | 581 } |
| 582 } | 582 } |
| 583 } | 583 } |
| OLD | NEW |