| 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 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 | 308 |
| 309 int _decodeByte(int byte) => ((byte & 0xFF) == byte) ? byte : -1; | 309 int _decodeByte(int byte) => ((byte & 0xFF) == byte) ? byte : -1; |
| 310 } | 310 } |
| 311 | 311 |
| 312 | 312 |
| 313 abstract class _SingleByteEncoder | 313 abstract class _SingleByteEncoder |
| 314 extends StreamEventTransformer<String, List<int>> { | 314 extends StreamEventTransformer<String, List<int>> { |
| 315 void handleData(String data, EventSink<List<int>> sink) { | 315 void handleData(String data, EventSink<List<int>> sink) { |
| 316 var bytes = _encode(data); | 316 var bytes = _encode(data); |
| 317 if (bytes == null) { | 317 if (bytes == null) { |
| 318 sink.addError( | 318 sink.addError(new FormatException("Invalid character for encoding")); |
| 319 new AsyncError( | |
| 320 new FormatException("Invalid character for encoding"))); | |
| 321 sink.close(); | 319 sink.close(); |
| 322 } else { | 320 } else { |
| 323 sink.add(bytes); | 321 sink.add(bytes); |
| 324 } | 322 } |
| 325 } | 323 } |
| 326 | 324 |
| 327 List<int> _encode(String string); | 325 List<int> _encode(String string); |
| 328 } | 326 } |
| 329 | 327 |
| 330 | 328 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 365 | 363 |
| 366 // Utility class for decoding Windows current code page data delivered | 364 // Utility class for decoding Windows current code page data delivered |
| 367 // as a stream of bytes. | 365 // as a stream of bytes. |
| 368 class _WindowsCodePageDecoder extends StreamEventTransformer<List<int>, String>
{ | 366 class _WindowsCodePageDecoder extends StreamEventTransformer<List<int>, String>
{ |
| 369 void handleData(List<int> data, EventSink<String> sink) { | 367 void handleData(List<int> data, EventSink<String> sink) { |
| 370 sink.add(_decodeBytes(data)); | 368 sink.add(_decodeBytes(data)); |
| 371 } | 369 } |
| 372 | 370 |
| 373 external static String _decodeBytes(List<int> bytes); | 371 external static String _decodeBytes(List<int> bytes); |
| 374 } | 372 } |
| OLD | NEW |