| 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 const SYSTEM_ENCODING = const SystemEncoding(); | 7 const SYSTEM_ENCODING = const SystemEncoding(); |
| 8 | 8 |
| 9 /** | 9 /** |
| 10 * The system encoding is the current code page on Windows and UTF-8 on | 10 * The system encoding is the current code page on Windows and UTF-8 on |
| 11 * Linux and Mac. | 11 * Linux and Mac. |
| 12 */ | 12 */ |
| 13 class SystemEncoding extends Encoding { | 13 class SystemEncoding extends Encoding { |
| 14 const SystemEncoding(); | 14 const SystemEncoding(); |
| 15 | 15 |
| 16 String get name => 'system'; |
| 17 |
| 16 List<int> encode(String input) => encoder.convert(input); | 18 List<int> encode(String input) => encoder.convert(input); |
| 17 String decode(List<int> encoded) => decoder.convert(encoded); | 19 String decode(List<int> encoded) => decoder.convert(encoded); |
| 18 | 20 |
| 19 Converter<String, List<int>> get encoder { | 21 Converter<String, List<int>> get encoder { |
| 20 if (Platform.operatingSystem == "windows") { | 22 if (Platform.operatingSystem == "windows") { |
| 21 return const _WindowsCodePageEncoder(); | 23 return const _WindowsCodePageEncoder(); |
| 22 } else { | 24 } else { |
| 23 return const Utf8Encoder(); | 25 return const Utf8Encoder(); |
| 24 } | 26 } |
| 25 } | 27 } |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 _WindowsCodePageDecoderSink(this._sink); | 122 _WindowsCodePageDecoderSink(this._sink); |
| 121 | 123 |
| 122 void close() { | 124 void close() { |
| 123 _sink.close(); | 125 _sink.close(); |
| 124 } | 126 } |
| 125 | 127 |
| 126 void add(List<int> bytes) { | 128 void add(List<int> bytes) { |
| 127 _sink.add(_WindowsCodePageDecoder._decodeBytes(bytes)); | 129 _sink.add(_WindowsCodePageDecoder._decodeBytes(bytes)); |
| 128 } | 130 } |
| 129 } | 131 } |
| OLD | NEW |