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

Unified Diff: pkg/http/lib/src/utils.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 | « no previous file | pkg/http/test/utils.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/http/lib/src/utils.dart
diff --git a/pkg/http/lib/src/utils.dart b/pkg/http/lib/src/utils.dart
index 65c47997b1e6991c5cf460fe4ae8659432901262..b626b1aa203c2cf381c0e36b8e06b5a345a86bf9 100644
--- a/pkg/http/lib/src/utils.dart
+++ b/pkg/http/lib/src/utils.dart
@@ -78,30 +78,20 @@ List<String> split1(String toSplit, String pattern) {
Encoding encodingForCharset(
String charset, [Encoding fallback = Encoding.ISO_8859_1]) {
if (charset == null) return fallback;
- var encoding = _encodingForCharset(charset);
+ var encoding = Encoding.fromName(charset);
return encoding == null ? fallback : encoding;
}
+
/// Returns the [Encoding] that corresponds to [charset]. Throws a
/// [FormatException] if no [Encoding] was found that corresponds to [charset].
/// [charset] may not be null.
Encoding requiredEncodingForCharset(String charset) {
- var encoding = _encodingForCharset(charset);
+ var encoding = Encoding.fromName(charset);
if (encoding != null) return encoding;
throw new FormatException('Unsupported encoding "$charset".');
}
-/// Returns the [Encoding] that corresponds to [charset]. Returns null if no
-/// [Encoding] was found that corresponds to [charset]. [charset] may not be
-/// null.
-Encoding _encodingForCharset(String charset) {
- charset = charset.toLowerCase();
- if (charset == 'ascii' || charset == 'us-ascii') return Encoding.ASCII;
- if (charset == 'utf-8') return Encoding.UTF_8;
- if (charset == 'iso-8859-1') return Encoding.ISO_8859_1;
- return null;
-}
-
/// Converts [bytes] into a [String] according to [encoding].
String decodeString(List<int> bytes, Encoding encoding) {
// TODO(nweiz): implement this once issue 6284 is fixed.
« no previous file with comments | « no previous file | pkg/http/test/utils.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698