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

Side by Side Diff: tests/standalone/io/process_std_io_script2.dart

Issue 16959004: Remove Encoding.BINARY (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 6 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 | « tests/standalone/io/process_run_output_test.dart ('k') | no next file » | no next file with comments »
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 // Utility script to echo strings in various formats to stdout or 5 // Utility script to echo strings in various formats to stdout or
6 // stderr. 6 // stderr.
7 7
8 import "dart:io"; 8 import "dart:io";
9 9
10 writeData(data, encoding, stream) { 10 writeData(data, encoding, stream) {
11 if (stream == "stdout") { 11 if (stream == "stdout") {
12 if (encoding == Encoding.BINARY) { 12 if (encoding == null) {
13 stdout.add(data); 13 stdout.add(data);
14 } else { 14 } else {
15 stdout.encoding = encoding; 15 stdout.encoding = encoding;
16 stdout.write(data); 16 stdout.write(data);
17 } 17 }
18 } else if (stream == "stderr") { 18 } else if (stream == "stderr") {
19 if (encoding == Encoding.BINARY) { 19 if (encoding == null) {
20 stderr.add(data); 20 stderr.add(data);
21 } else { 21 } else {
22 stderr.encoding = encoding; 22 stderr.encoding = encoding;
23 stderr.write(data); 23 stderr.write(data);
24 } 24 }
25 } 25 }
26 } 26 }
27 27
28 main() { 28 main() {
29 var asciiString = 'abc'; 29 var asciiString = 'abc';
30 var latin1String = 'æøå'; 30 var latin1String = 'æøå';
31 var utf8String = new String.fromCharCodes([955]); 31 var utf8String = new String.fromCharCodes([955]);
32 var binary = [0, 1, 2]; 32 var binary = [0, 1, 2];
33 var options = new Options(); 33 var options = new Options();
34 if (options.arguments.length > 1) { 34 if (options.arguments.length > 1) {
35 var stream = options.arguments[1]; 35 var stream = options.arguments[1];
36 if (options.arguments[0] == "ascii") { 36 if (options.arguments[0] == "ascii") {
37 writeData(asciiString, Encoding.ASCII, stream); 37 writeData(asciiString, Encoding.ASCII, stream);
38 } else if (options.arguments[0] == "latin1") { 38 } else if (options.arguments[0] == "latin1") {
39 writeData(latin1String, Encoding.ISO_8859_1, stream); 39 writeData(latin1String, Encoding.ISO_8859_1, stream);
40 } else if (options.arguments[0] == "utf8") { 40 } else if (options.arguments[0] == "utf8") {
41 writeData(utf8String, Encoding.UTF_8, stream); 41 writeData(utf8String, Encoding.UTF_8, stream);
42 } else if (options.arguments[0] == "binary") { 42 } else if (options.arguments[0] == "binary") {
43 writeData(binary, Encoding.BINARY, stream); 43 writeData(binary, null, stream);
44 } 44 }
45 } 45 }
46 } 46 }
OLDNEW
« no previous file with comments | « tests/standalone/io/process_run_output_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698