Index: sdk/lib/codec/encoding.dart |
diff --git a/sdk/lib/codec/encoding.dart b/sdk/lib/codec/encoding.dart |
new file mode 100644 |
index 0000000000000000000000000000000000000000..800c403cbab8845a96c900474107c0a34ce29436 |
--- /dev/null |
+++ b/sdk/lib/codec/encoding.dart |
@@ -0,0 +1,29 @@ |
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
+// for details. All rights reserved. Use of this source code is governed by a |
+// BSD-style license that can be found in the LICENSE file. |
+ |
+part of dart.codec; |
+ |
+/** |
+ * Open-ended Encoding enum. |
+ */ |
+// TODO(floitsch): dart:io already has an Encoding class. If we can't |
+// consolitate them, we need to remove `Encoding` here. |
+// TODO(floitsch): add other encodings, like ASCII and ISO_8859_1. |
Lasse Reichstein Nielsen
2013/07/12 11:50:47
These are partial encodings of strings (where stri
floitsch
2013/07/12 16:09:15
If we intend to replace the Encoding enum in dart:
|
+abstract class Encoding extends Codec<String, List<int>> { |
+ const Encoding(); |
+ |
+ static const UTF8 = const Utf8Codec(); |
Lasse Reichstein Nielsen
2013/07/12 11:50:47
Put this outside the class. Since it's an open-end
floitsch
2013/07/12 16:09:15
Done.
|
+} |
+ |
+/** |
+ * A [Utf8Codec] encodes strings to utf-8 codeunits (bytes) and decodes |
Lasse Reichstein Nielsen
2013/07/12 11:50:47
codeunits -> code units
floitsch
2013/07/12 16:09:15
Done.
|
+ * utf-8 codeunits to strings. |
Lasse Reichstein Nielsen
2013/07/12 11:50:47
utf-8 -> UTF-8
codeunits -> code units
floitsch
2013/07/12 16:09:15
Done.
|
+ */ |
+// TODO(floitsch): Needs a way to specify a replacement character for decoding. |
Lasse Reichstein Nielsen
2013/07/12 11:50:47
Default replacement character is U+FFFD (aka. REPL
floitsch
2013/07/12 16:09:15
Changed comment.
|
+class Utf8Codec extends Encoding { |
+ const Utf8Codec(); |
+ |
+ Converter<String, List<int>> get encoder => new Utf8Encoder(); |
+ Converter<List<int>, String> get decoder => new Utf8Decoder(); |
+} |