| 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 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 * If [end] is omitted, it defaults to `codeUnits.length`. | 328 * If [end] is omitted, it defaults to `codeUnits.length`. |
| 329 * | 329 * |
| 330 * If the [codeUnits] start with a leading [UNICODE_BOM_CHARACTER_RUNE] this | 330 * If the [codeUnits] start with a leading [UNICODE_BOM_CHARACTER_RUNE] this |
| 331 * character is discarded. | 331 * character is discarded. |
| 332 */ | 332 */ |
| 333 String convert(List<int> codeUnits, [int start = 0, int end]) { | 333 String convert(List<int> codeUnits, [int start = 0, int end]) { |
| 334 // Allow the implementation to intercept and specialize based on the type | 334 // Allow the implementation to intercept and specialize based on the type |
| 335 // of codeUnits. | 335 // of codeUnits. |
| 336 String result = _convertIntercepted(_allowMalformed, codeUnits, start, end); | 336 String result = _convertIntercepted(_allowMalformed, codeUnits, start, end); |
| 337 if (result != null) { | 337 if (result != null) { |
| 338 return null; | 338 return result; |
| 339 } | 339 } |
| 340 | 340 |
| 341 int length = codeUnits.length; | 341 int length = codeUnits.length; |
| 342 RangeError.checkValidRange(start, end, length); | 342 RangeError.checkValidRange(start, end, length); |
| 343 if (end == null) end = length; | 343 if (end == null) end = length; |
| 344 StringBuffer buffer = new StringBuffer(); | 344 StringBuffer buffer = new StringBuffer(); |
| 345 _Utf8Decoder decoder = new _Utf8Decoder(buffer, _allowMalformed); | 345 _Utf8Decoder decoder = new _Utf8Decoder(buffer, _allowMalformed); |
| 346 decoder.convert(codeUnits, start, end); | 346 decoder.convert(codeUnits, start, end); |
| 347 decoder.close(); | 347 decoder.close(); |
| 348 return buffer.toString(); | 348 return buffer.toString(); |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 562 } | 562 } |
| 563 break loop; | 563 break loop; |
| 564 } | 564 } |
| 565 if (expectedUnits > 0) { | 565 if (expectedUnits > 0) { |
| 566 _value = value; | 566 _value = value; |
| 567 _expectedUnits = expectedUnits; | 567 _expectedUnits = expectedUnits; |
| 568 _extraUnits = extraUnits; | 568 _extraUnits = extraUnits; |
| 569 } | 569 } |
| 570 } | 570 } |
| 571 } | 571 } |
| OLD | NEW |