| 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 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 const Utf8Decoder({ bool allowMalformed: false }) | 323 const Utf8Decoder({ bool allowMalformed: false }) |
| 324 : this._allowMalformed = allowMalformed; | 324 : this._allowMalformed = allowMalformed; |
| 325 | 325 |
| 326 /** | 326 /** |
| 327 * Converts the UTF-8 [codeUnits] (a list of unsigned 8-bit integers) to the | 327 * Converts the UTF-8 [codeUnits] (a list of unsigned 8-bit integers) to the |
| 328 * corresponding string. | 328 * corresponding string. |
| 329 * | 329 * |
| 330 * Uses the code units from [start] to, but no including, [end]. | 330 * Uses the code units from [start] to, but no including, [end]. |
| 331 * If [end] is omitted, it defaults to `codeUnits.length`. | 331 * If [end] is omitted, it defaults to `codeUnits.length`. |
| 332 * | 332 * |
| 333 * If the [codeUnits] start with a leading [UNICODE_BOM_CHARACTER_RUNE] this | 333 * If the [codeUnits] start with the encoding of a |
| 334 * character is discarded. | 334 * [UNICODE_BOM_CHARACTER_RUNE], that character is discarded. |
| 335 */ | 335 */ |
| 336 String convert(List<int> codeUnits, [int start = 0, int end]) { | 336 String convert(List<int> codeUnits, [int start = 0, int end]) { |
| 337 // Allow the implementation to intercept and specialize based on the type | 337 // Allow the implementation to intercept and specialize based on the type |
| 338 // of codeUnits. | 338 // of codeUnits. |
| 339 String result = _convertIntercepted(_allowMalformed, codeUnits, start, end); | 339 String result = _convertIntercepted(_allowMalformed, codeUnits, start, end); |
| 340 if (result != null) { | 340 if (result != null) { |
| 341 return result; | 341 return result; |
| 342 } | 342 } |
| 343 | 343 |
| 344 int length = codeUnits.length; | 344 int length = codeUnits.length; |
| (...skipping 229 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 |