Chromium Code Reviews| 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) |