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

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

Issue 20374003: Add transformer support to Converters. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Upload Created 7 years, 4 months 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 | Annotate | Revision Log
« no previous file with comments | « sdk/lib/convert/json.dart ('k') | tests/lib/convert/chunked_conversion2_test.dart » ('j') | 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 /** 7 /**
8 * An instance of the default implementation of the [Utf8Codec]. 8 * An instance of the default implementation of the [Utf8Codec].
9 * 9 *
10 * This instance provides a convenient access to the most common UTF-8 10 * This instance provides a convenient access to the most common UTF-8
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 * The converter works more efficiently if the given [sink] is a 93 * The converter works more efficiently if the given [sink] is a
94 * [ByteConversionSink]. 94 * [ByteConversionSink].
95 */ 95 */
96 StringConversionSink startChunkedConversion( 96 StringConversionSink startChunkedConversion(
97 ChunkedConversionSink<List<int>> sink) { 97 ChunkedConversionSink<List<int>> sink) {
98 if (sink is! ByteConversionSink) { 98 if (sink is! ByteConversionSink) {
99 sink = new ByteConversionSink.from(sink); 99 sink = new ByteConversionSink.from(sink);
100 } 100 }
101 return new _Utf8EncoderSink(sink); 101 return new _Utf8EncoderSink(sink);
102 } 102 }
103
104 // Override the base-classes bind, to provide a better type.
105 Stream<List<int>> bind(Stream<String> stream) => super.bind(stream);
103 } 106 }
104 107
105 /** 108 /**
106 * This class encodes Strings to UTF-8 code units (unsigned 8 bit integers). 109 * This class encodes Strings to UTF-8 code units (unsigned 8 bit integers).
107 */ 110 */
108 // TODO(floitsch): make this class public. 111 // TODO(floitsch): make this class public.
109 class _Utf8Encoder { 112 class _Utf8Encoder {
110 int _carry = 0; 113 int _carry = 0;
111 int _bufferIndex = 0; 114 int _bufferIndex = 0;
112 final List<int> _buffer; 115 final List<int> _buffer;
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 ByteConversionSink startChunkedConversion( 313 ByteConversionSink startChunkedConversion(
311 ChunkedConversionSink<String> sink) { 314 ChunkedConversionSink<String> sink) {
312 StringConversionSink stringSink; 315 StringConversionSink stringSink;
313 if (sink is StringConversionSink) { 316 if (sink is StringConversionSink) {
314 stringSink = sink; 317 stringSink = sink;
315 } else { 318 } else {
316 stringSink = new StringConversionSink.from(sink); 319 stringSink = new StringConversionSink.from(sink);
317 } 320 }
318 return stringSink.asUtf8Sink(_allowMalformed); 321 return stringSink.asUtf8Sink(_allowMalformed);
319 } 322 }
323
324 // Override the base-classes bind, to provide a better type.
325 Stream<String> bind(Stream<List<int>> stream) => super.bind(stream);
320 } 326 }
321 327
322 // UTF-8 constants. 328 // UTF-8 constants.
323 const int _ONE_BYTE_LIMIT = 0x7f; // 7 bits 329 const int _ONE_BYTE_LIMIT = 0x7f; // 7 bits
324 const int _TWO_BYTE_LIMIT = 0x7ff; // 11 bits 330 const int _TWO_BYTE_LIMIT = 0x7ff; // 11 bits
325 const int _THREE_BYTE_LIMIT = 0xffff; // 16 bits 331 const int _THREE_BYTE_LIMIT = 0xffff; // 16 bits
326 const int _FOUR_BYTE_LIMIT = 0x10ffff; // 21 bits, truncated to Unicode max. 332 const int _FOUR_BYTE_LIMIT = 0x10ffff; // 21 bits, truncated to Unicode max.
327 333
328 // UTF-16 constants. 334 // UTF-16 constants.
329 const int _SURROGATE_MASK = 0xF800; 335 const int _SURROGATE_MASK = 0xF800;
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 } 487 }
482 break loop; 488 break loop;
483 } 489 }
484 if (expectedUnits > 0) { 490 if (expectedUnits > 0) {
485 _value = value; 491 _value = value;
486 _expectedUnits = expectedUnits; 492 _expectedUnits = expectedUnits;
487 _extraUnits = extraUnits; 493 _extraUnits = extraUnits;
488 } 494 }
489 } 495 }
490 } 496 }
OLDNEW
« no previous file with comments | « sdk/lib/convert/json.dart ('k') | tests/lib/convert/chunked_conversion2_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698