| 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.io; | 5 part of dart.io; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * String encodings. | 8 * String encodings. |
| 9 */ | 9 */ |
| 10 class Encoding { | 10 class Encoding { |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 | 210 |
| 211 class LineTransformer extends StreamEventTransformer<String, String> { | 211 class LineTransformer extends StreamEventTransformer<String, String> { |
| 212 const int _LF = 10; | 212 const int _LF = 10; |
| 213 const int _CR = 13; | 213 const int _CR = 13; |
| 214 | 214 |
| 215 StringBuffer _buffer = new StringBuffer(); | 215 StringBuffer _buffer = new StringBuffer(); |
| 216 String _carry; | 216 String _carry; |
| 217 | 217 |
| 218 void _handle(String data, EventSink<String> sink, bool isClosing) { | 218 void _handle(String data, EventSink<String> sink, bool isClosing) { |
| 219 if (_carry != null) { | 219 if (_carry != null) { |
| 220 data = _carry.concat(data); | 220 data = _carry + data; |
| 221 _carry = null; | 221 _carry = null; |
| 222 } | 222 } |
| 223 int startPos = 0; | 223 int startPos = 0; |
| 224 int pos = 0; | 224 int pos = 0; |
| 225 while (pos < data.length) { | 225 while (pos < data.length) { |
| 226 int skip = 0; | 226 int skip = 0; |
| 227 int char = data.codeUnitAt(pos); | 227 int char = data.codeUnitAt(pos); |
| 228 if (char == _LF) { | 228 if (char == _LF) { |
| 229 skip = 1; | 229 skip = 1; |
| 230 } else if (char == _CR) { | 230 } else if (char == _CR) { |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 | 361 |
| 362 // Utility class for decoding Windows current code page data delivered | 362 // Utility class for decoding Windows current code page data delivered |
| 363 // as a stream of bytes. | 363 // as a stream of bytes. |
| 364 class _WindowsCodePageDecoder extends StreamEventTransformer<List<int>, String>
{ | 364 class _WindowsCodePageDecoder extends StreamEventTransformer<List<int>, String>
{ |
| 365 void handleData(List<int> data, EventSink<String> sink) { | 365 void handleData(List<int> data, EventSink<String> sink) { |
| 366 sink.add(_decodeBytes(data)); | 366 sink.add(_decodeBytes(data)); |
| 367 } | 367 } |
| 368 | 368 |
| 369 external static String _decodeBytes(List<int> bytes); | 369 external static String _decodeBytes(List<int> bytes); |
| 370 } | 370 } |
| OLD | NEW |