Index: sdk/lib/convert/utf.dart |
diff --git a/sdk/lib/convert/utf.dart b/sdk/lib/convert/utf.dart |
new file mode 100644 |
index 0000000000000000000000000000000000000000..1e70eca80c0c8da7ca8c793fc2ab978b18ef4ae3 |
--- /dev/null |
+++ b/sdk/lib/convert/utf.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.convert; |
+ |
+/** |
+ * A [Utf8Encoder] converts strings to their utf-8 code units (a list of |
Lasse Reichstein Nielsen
2013/07/12 11:50:47
utf -> UTF
floitsch
2013/07/12 16:09:15
Done.
|
+ * 8-bit integers). |
Lasse Reichstein Nielsen
2013/07/12 11:50:47
unsigned 8-bit integers,
or just integer in the ra
floitsch
2013/07/12 16:09:15
Done.
|
+ */ |
+class Utf8Encoder extends Converter<String, List<int>> { |
+ /** |
+ * Converts [str] to its utf-8 code units (a list of |
Lasse Reichstein Nielsen
2013/07/12 11:50:47
str -> string
utf-8 -> UTF-8
floitsch
2013/07/12 16:09:15
Done.
|
+ * 8-bit integers). |
+ */ |
+ List<int> convert(String str) => OLD_UTF_LIB.encodeUtf8(str); |
+} |
+ |
+/** |
+ * A [Utf8Decoder] converts utf-8 code units (lists of 8-bit ints) to strings. |
Lasse Reichstein Nielsen
2013/07/12 11:50:47
UTF-8
unsigned
"to a string"
floitsch
2013/07/12 16:09:15
Done.
|
+ */ |
+class Utf8Decoder extends Converter<List<int>, String> { |
+ /** |
+ * Converts the utf-8 [codeUnits] (a list of 8-bit integers) to the |
Lasse Reichstein Nielsen
2013/07/12 11:50:47
ditto
floitsch
2013/07/12 16:09:15
Done.
|
+ * corresponding string. |
+ */ |
+ // TODO(floitsch): allow to configure the decoder (for example the replacement |
+ // character). |
+ String convert(List<int> codeUnits) => OLD_UTF_LIB.decodeUtf8(codeUnits); |
+} |