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

Side by Side Diff: pkg/barback/lib/src/asset.dart

Issue 22909059: Some more removals of dart:utf. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Change ArgumentError to FormatException. Created 7 years, 3 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | pkg/barback/test/asset_test.dart » ('j') | tests/corelib/uri_test.dart » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library barback.asset; 5 library barback.asset;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:convert' show Encoding, UTF8; 8 import 'dart:convert';
9 import 'dart:io'; 9 import 'dart:io';
10 import 'dart:utf';
11 10
12 import 'asset_id.dart'; 11 import 'asset_id.dart';
13 import 'utils.dart'; 12 import 'utils.dart';
14 13
15 /// A blob of content. 14 /// A blob of content.
16 /// 15 ///
17 /// Assets may come from the file system, or as the output of a [Transformer]. 16 /// Assets may come from the file system, or as the output of a [Transformer].
18 /// They are identified by [AssetId]. 17 /// They are identified by [AssetId].
19 abstract class Asset { 18 abstract class Asset {
20 /// The ID for this asset. 19 /// The ID for this asset.
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 class _StringAsset extends Asset { 110 class _StringAsset extends Asset {
112 final String _contents; 111 final String _contents;
113 112
114 _StringAsset(AssetId id, this._contents) 113 _StringAsset(AssetId id, this._contents)
115 : super(id); 114 : super(id);
116 115
117 Future<String> readAsString({Encoding encoding}) => 116 Future<String> readAsString({Encoding encoding}) =>
118 new Future.value(_contents); 117 new Future.value(_contents);
119 118
120 Stream<List<int>> read() => 119 Stream<List<int>> read() =>
121 new Future<List<int>>.value(encodeUtf8(_contents)).asStream(); 120 new Future<List<int>>.value(UTF8.encode(_contents)).asStream();
122 121
123 String toString() { 122 String toString() {
124 // Don't show the whole string if it's long. 123 // Don't show the whole string if it's long.
125 var contents = _contents; 124 var contents = _contents;
126 if (contents.length > 40) { 125 if (contents.length > 40) {
127 contents = contents.substring(0, 20) + " ... " + 126 contents = contents.substring(0, 20) + " ... " +
128 contents.substring(contents.length - 20); 127 contents.substring(contents.length - 20);
129 } 128 }
130 129
131 contents = _escape(contents); 130 contents = _escape(contents);
132 return 'String "$contents"'; 131 return 'String "$contents"';
133 } 132 }
134 133
135 String _escape(String string) { 134 String _escape(String string) {
136 return string 135 return string
137 .replaceAll("\"", r'\"') 136 .replaceAll("\"", r'\"')
138 .replaceAll("\n", r"\n") 137 .replaceAll("\n", r"\n")
139 .replaceAll("\r", r"\r") 138 .replaceAll("\r", r"\r")
140 .replaceAll("\t", r"\t"); 139 .replaceAll("\t", r"\t");
141 } 140 }
142 } 141 }
OLDNEW
« no previous file with comments | « no previous file | pkg/barback/test/asset_test.dart » ('j') | tests/corelib/uri_test.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698