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

Unified Diff: sdk/lib/io/string_transformer.dart

Issue 12504006: Make IOSink implement StringSink (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fixed accidental edit Created 7 years, 9 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
Index: sdk/lib/io/string_transformer.dart
diff --git a/sdk/lib/io/string_transformer.dart b/sdk/lib/io/string_transformer.dart
index 2b02639f474f2cb64d2c5a5a75b346f43a20bbcf..2deb925a3d09520608e9dc4d9acd0b3a08c0d6d2 100644
--- a/sdk/lib/io/string_transformer.dart
+++ b/sdk/lib/io/string_transformer.dart
@@ -13,6 +13,30 @@ class Encoding {
static const Encoding ASCII = const Encoding._internal("us-ascii");
/**
+ * Gets an [Encoding] object from the name of the character set
+ * name. The names used are the IANA official names for the
+ * character set (see
+ * http://www.iana.org/assignments/character-sets/character-sets.xml).
+ *
+ * The [name] passed is case insensitive.
+ *
+ * If character set is not supported [:null:] is returned.
+ */
+ static Encoding fromName(String name) {
+ if (name == null) return null;
+ name = name.toLowerCase();
+ if (name == "iso-8859-1" || name == "iso_8859-1" || name == "latin1") {
+ return ISO_8859_1;
+ } else if (name == "utf-8") {
+ return UTF_8;
+ } else if (name == "us-ascii" || name == "ascii") {
+ return ASCII;
+ } else {
+ return null;
+ }
nweiz 2013/03/07 19:32:05 It would be nice if we could support all the chara
Søren Gjesse 2013/03/08 09:47:46 Done.
+ }
+
+ /**
* Name of the encoding. This will be the lower-case version of one of the
* IANA official names for the character set (see
* http://www.iana.org/assignments/character-sets/character-sets.xml)

Powered by Google App Engine
This is Rietveld 408576698