| 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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 | 155 |
| 156 class LineTransformer extends StreamEventTransformer<String, String> { | 156 class LineTransformer extends StreamEventTransformer<String, String> { |
| 157 const int _LF = 10; | 157 const int _LF = 10; |
| 158 const int _CR = 13; | 158 const int _CR = 13; |
| 159 | 159 |
| 160 final StringBuffer _buffer = new StringBuffer(); | 160 final StringBuffer _buffer = new StringBuffer(); |
| 161 String _carry; | 161 String _carry; |
| 162 | 162 |
| 163 void _handle(String data, StreamSink<String> sink, bool isClosing) { | 163 void _handle(String data, StreamSink<String> sink, bool isClosing) { |
| 164 if (_carry != null) { | 164 if (_carry != null) { |
| 165 data = _carry.concat(data); | 165 data = _carry + data; |
| 166 _carry = null; | 166 _carry = null; |
| 167 } | 167 } |
| 168 int startPos = 0; | 168 int startPos = 0; |
| 169 int pos = 0; | 169 int pos = 0; |
| 170 while (pos < data.length) { | 170 while (pos < data.length) { |
| 171 int skip = 0; | 171 int skip = 0; |
| 172 int char = data.codeUnitAt(pos); | 172 int char = data.codeUnitAt(pos); |
| 173 if (char == _LF) { | 173 if (char == _LF) { |
| 174 skip = 1; | 174 skip = 1; |
| 175 } else if (char == _CR) { | 175 } else if (char == _CR) { |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 | 306 |
| 307 // Utility class for decoding Windows current code page data delivered | 307 // Utility class for decoding Windows current code page data delivered |
| 308 // as a stream of bytes. | 308 // as a stream of bytes. |
| 309 class _WindowsCodePageDecoder extends StreamEventTransformer<List<int>, String>
{ | 309 class _WindowsCodePageDecoder extends StreamEventTransformer<List<int>, String>
{ |
| 310 void handleData(List<int> data, StreamSink<String> sink) { | 310 void handleData(List<int> data, StreamSink<String> sink) { |
| 311 sink.add(_decodeBytes(data)); | 311 sink.add(_decodeBytes(data)); |
| 312 } | 312 } |
| 313 | 313 |
| 314 external static String _decodeBytes(List<int> bytes); | 314 external static String _decodeBytes(List<int> bytes); |
| 315 } | 315 } |
| OLD | NEW |