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

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: Addressed second round of review comments 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
« no previous file with comments | « sdk/lib/io/io_sink.dart ('k') | sdk/lib/io/websocket_impl.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..30f74fe34fa5eeaa91e908ae1eae61c4d9d3ad97 100644
--- a/sdk/lib/io/string_transformer.dart
+++ b/sdk/lib/io/string_transformer.dart
@@ -12,6 +12,54 @@ class Encoding {
static const Encoding ISO_8859_1 = const Encoding._internal("iso-8859-1");
static const Encoding ASCII = const Encoding._internal("us-ascii");
+ // All aliasses (in lowercase) of supported encoding from
+ // http://www.iana.org/assignments/character-sets/character-sets.xml.
+ static Map<String, Encoding> _nameToEncoding = <String, Encoding> {
+ // ISO_8859-1:1987.
+ "iso_8859-1:1987": ISO_8859_1,
+ "iso-ir-100": ISO_8859_1,
+ "iso_8859-1": ISO_8859_1,
+ "iso-8859-1": ISO_8859_1,
+ "latin1": ISO_8859_1,
+ "l1": ISO_8859_1,
+ "ibm819": ISO_8859_1,
+ "cp819": ISO_8859_1,
+ "csisolatin1": ISO_8859_1,
+
+ // US-ASCII.
+ "iso-ir-6": ASCII,
+ "ansi_x3.4-1968": ASCII,
+ "ansi_x3.4-1986": ASCII,
+ "iso_646.irv:1991": ASCII,
+ "iso646-us": ASCII,
+ "us-ascii": ASCII,
+ "us": ASCII,
+ "ibm367": ASCII,
+ "cp367": ASCII,
+ "csascii": ASCII,
+ "ascii": ASCII, // This is not in the IANA official names.
+
+ // UTF-8.
+ "csutf8": UTF_8,
+ "utf-8": UTF_8
+ };
+
+ /**
+ * 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();
+ return _nameToEncoding[name];
+ }
+
/**
* Name of the encoding. This will be the lower-case version of one of the
* IANA official names for the character set (see
« no previous file with comments | « sdk/lib/io/io_sink.dart ('k') | sdk/lib/io/websocket_impl.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698