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

Unified Diff: pkg/http/lib/src/utils.dart

Issue 22872012: Remove Encoding-enum from dart:io and add interface in dart:convert. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix ddbg. Created 7 years, 4 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: 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

Powered by Google App Engine
This is Rietveld 408576698