Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8)

Unified Diff: sdk/lib/codec/encoding.dart

Issue 19000006: First version of Codecs and Converters. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comment. Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sdk/lib/codec/codec_sources.gypi ('k') | sdk/lib/codec/json.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..50b724be6d398d50ead3e91740080f43c604f47c
--- /dev/null
+++ b/sdk/lib/codec/encoding.dart
@@ -0,0 +1,30 @@
+// 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.
+abstract class Encoding extends Codec<String, List<int>> {
+ const Encoding();
+}
+
+// TODO(floitsch): add other encodings, like ASCII and ISO_8859_1.
+const UTF8 = const Utf8Codec();
+
+/**
+ * A [Utf8Codec] encodes strings to utf-8 code units (bytes) and decodes
+ * UTF-8 code units to strings.
+ */
+// TODO(floitsch): Needs a way to specify if decoding should throw or use
+// the replacement character.
+class Utf8Codec extends Encoding {
+ const Utf8Codec();
+
+ Converter<String, List<int>> get encoder => new Utf8Encoder();
+ Converter<List<int>, String> get decoder => new Utf8Decoder();
+}
« no previous file with comments | « sdk/lib/codec/codec_sources.gypi ('k') | sdk/lib/codec/json.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698