Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(184)

Side by Side Diff: sdk/lib/convert/utf.dart

Issue 1449273002: fix Utf8Decoder hook. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698