Chromium Code Reviews| Index: pkg/http/lib/src/utils.dart |
| diff --git a/pkg/http/lib/src/utils.dart b/pkg/http/lib/src/utils.dart |
| index 420a3d55441a7ffe25e8188a45db378cdff1dc3c..c1f74be4426b4fa6e9f110e9a9e2c124cf477cf1 100644 |
| --- a/pkg/http/lib/src/utils.dart |
| +++ b/pkg/http/lib/src/utils.dart |
| @@ -5,9 +5,9 @@ |
| library utils; |
| import 'dart:async'; |
| +import 'dart:convert'; |
| import 'dart:io'; |
| import 'dart:typed_data'; |
| -import 'dart:utf'; |
| import 'byte_stream.dart'; |
| @@ -66,9 +66,9 @@ List<String> split1(String toSplit, String pattern) { |
| /// [charset] is null or if no [Encoding] was found that corresponds to |
| /// [charset]. |
| Encoding encodingForCharset( |
| - String charset, [Encoding fallback = Encoding.ISO_8859_1]) { |
| + String charset, [Encoding fallback = LATIN1]) { |
| if (charset == null) return fallback; |
| - var encoding = Encoding.fromName(charset); |
| + var encoding = encodingFromName(charset); |
| return encoding == null ? fallback : encoding; |
| } |
| @@ -77,21 +77,19 @@ Encoding encodingForCharset( |
| /// [FormatException] if no [Encoding] was found that corresponds to [charset]. |
| /// [charset] may not be null. |
| Encoding requiredEncodingForCharset(String charset) { |
| - var encoding = Encoding.fromName(charset); |
| + var encoding = encodingFromName(charset); |
| if (encoding != null) return encoding; |
| throw new FormatException('Unsupported encoding "$charset".'); |
| } |
| /// Converts [bytes] into a [String] according to [encoding]. |
| String decodeString(List<int> bytes, Encoding encoding) { |
|
nweiz
2013/08/23 19:40:00
This (and [encodeString] should just be replaced w
floitsch
2013/08/26 09:33:40
Done.
|
| - // TODO(nweiz): implement this once issue 6284 is fixed. |
| - return decodeUtf8(bytes); |
| + return encoding.decode(bytes); |
| } |
| /// Converts [string] into a byte array according to [encoding]. |
| List<int> encodeString(String string, Encoding encoding) { |
| - // TODO(nweiz): implement this once issue 6284 is fixed. |
| - return encodeUtf8(string); |
| + return encoding.encode(string); |
| } |
| /// A regular expression that matches strings that are composed entirely of |