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.utf; | 5 part of dart.utf; |
6 | 6 |
7 class _HelperStreamController<T> extends StreamController<T> { | 7 class _HelperStreamController<T> extends StreamController<T> { |
8 final Function onPauseChanged; | 8 final Function onPauseChanged; |
9 | 9 |
10 _HelperStreamController(this.onPauseChanged); | 10 _HelperStreamController(this.onPauseChanged); |
(...skipping 25 matching lines...) Expand all Loading... |
36 } | 36 } |
37 } | 37 } |
38 | 38 |
39 Stream<String> bind(Stream<List<int>> stream) { | 39 Stream<String> bind(Stream<List<int>> stream) { |
40 _subscription = stream.listen( | 40 _subscription = stream.listen( |
41 _onData, | 41 _onData, |
42 onError: _controller.signalError, | 42 onError: _controller.signalError, |
43 onDone: () { | 43 onDone: () { |
44 if (_carry != null) { | 44 if (_carry != null) { |
45 _controller.add(new String.fromCharCodes( | 45 _controller.add(new String.fromCharCodes( |
46 new List.fixedLength(_carry.length, fill: _replacementChar))); | 46 new List.filled(_carry.length, _replacementChar))); |
47 } | 47 } |
48 _controller.close(); | 48 _controller.close(); |
49 }, | 49 }, |
50 unsubscribeOnError: false); | 50 unsubscribeOnError: false); |
51 if (_paused) _subscription.pause(); | 51 if (_paused) _subscription.pause(); |
52 return _controller.stream; | 52 return _controller.stream; |
53 } | 53 } |
54 | 54 |
55 void _onData(List<int> bytes) { | 55 void _onData(List<int> bytes) { |
56 _buffer = <int>[]; | 56 _buffer = <int>[]; |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 } | 215 } |
216 for (int i = additionalBytes; i > 0; i--) { | 216 for (int i = additionalBytes; i > 0; i--) { |
217 // 10xxxxxx (xxxxxx is next 6 bits from the top). | 217 // 10xxxxxx (xxxxxx is next 6 bits from the top). |
218 bytes.add(((charCode >> (6 * (i - 1))) & 0x3F) | 0x80); | 218 bytes.add(((charCode >> (6 * (i - 1))) & 0x3F) | 0x80); |
219 } | 219 } |
220 pos += additionalBytes + 1; | 220 pos += additionalBytes + 1; |
221 } | 221 } |
222 return bytes; | 222 return bytes; |
223 } | 223 } |
224 } | 224 } |
OLD | NEW |