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

Unified Diff: pkg/barback/lib/src/asset.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 typo. 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
« no previous file with comments | « pkg/analyzer_experimental/bin/formatter.dart ('k') | pkg/barback/test/asset_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/barback/lib/src/asset.dart
diff --git a/pkg/barback/lib/src/asset.dart b/pkg/barback/lib/src/asset.dart
index 05a2202dfa612aa62c94d3d57b82f2941bd83ef1..db7a5ea2ca8c0788511ee1eed80f8c504faaab72 100644
--- a/pkg/barback/lib/src/asset.dart
+++ b/pkg/barback/lib/src/asset.dart
@@ -5,6 +5,7 @@
library barback.asset;
import 'dart:async';
+import 'dart:convert' show Encoding, UTF8;
import 'dart:io';
import 'dart:utf';
@@ -37,7 +38,7 @@ abstract class Asset {
///
/// If the asset was created from a [String] the original string is always
/// returned and [encoding] is ignored. Otherwise, the binary data of the
- /// asset is decoded using [encoding], which defaults to [Encoding.UTF_8].
+ /// asset is decoded using [encoding], which defaults to [UTF8].
Future<String> readAsString({Encoding encoding});
/// Streams the binary contents of the asset.
@@ -54,16 +55,9 @@ class _BinaryAsset extends Asset {
: super(id);
Future<String> readAsString({Encoding encoding}) {
- if (encoding == null) encoding = Encoding.UTF_8;
+ if (encoding == null) encoding = UTF8;
- // TODO(rnystrom): When #6284 is fixed, just use that. Until then, only
- // UTF-8 is supported. :(
- if (encoding != Encoding.UTF_8) {
- throw new UnsupportedError(
- "${encoding.name} is not a supported encoding.");
- }
-
- return new Future.value(decodeUtf8(_contents));
+ return new Future.value(encoding.decode(_contents));
}
Stream<List<int>> read() => new Future<List<int>>.value(_contents).asStream();
@@ -104,7 +98,7 @@ class _FileAsset extends Asset {
: super(id);
Future<String> readAsString({Encoding encoding}) {
- if (encoding == null) encoding = Encoding.UTF_8;
+ if (encoding == null) encoding = UTF8;
return _file.readAsString(encoding: encoding);
}
« no previous file with comments | « pkg/analyzer_experimental/bin/formatter.dart ('k') | pkg/barback/test/asset_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698