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

Unified Diff: sdk/lib/io/stdio.dart

Issue 2698813002: [dart:io][windows] Make unicode characters display correctly. (Closed)
Patch Set: Address comments Created 3 years, 10 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 | « sdk/lib/io/file_impl.dart ('k') | tests/standalone/io/console_unicode_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/io/stdio.dart
diff --git a/sdk/lib/io/stdio.dart b/sdk/lib/io/stdio.dart
index 86a0f8f8b88d246005c6a96bb6035a5106909c15..8c08023eff9afbc169b9026570ae7c72fe81368c 100644
--- a/sdk/lib/io/stdio.dart
+++ b/sdk/lib/io/stdio.dart
@@ -166,7 +166,7 @@ class Stdin extends _StdStream implements Stream<List<int>> {
* This class can also be used to check whether `stdout` or `stderr` is
* connected to a terminal and query some terminal properties.
*/
-class Stdout extends _StdSink implements IOSink {
+class Stdout extends _StdFileSink implements IOSink {
final int _fd;
IOSink _nonBlocking;
@@ -262,29 +262,64 @@ class _StdConsumer implements StreamConsumer<List<int>> {
}
}
-class _StdSink implements IOSink {
+class _StdSinkHelper implements IOSink {
final IOSink _sink;
+ final bool _isTranslatable;
- _StdSink(this._sink);
+ _StdSinkHelper(this._sink, this._isTranslatable);
Encoding get encoding => _sink.encoding;
void set encoding(Encoding encoding) {
_sink.encoding = encoding;
}
- void write(object) { _sink.write(object); }
- void writeln([object = "" ]) { _sink.writeln(object); }
- void writeAll(objects, [sep = ""]) { _sink.writeAll(objects, sep); }
- void add(List<int> data) { _sink.add(data); }
+
+ void set _translation(_FileTranslation t) {
+ if (_isTranslatable) {
+ _sink._target._file.translation = t;
+ }
+ }
+
+ void write(object) {
+ _translation = _FileTranslation.text;
+ _sink.write(object);
+ }
+ void writeln([object = "" ]) {
+ _translation = _FileTranslation.text;
+ _sink.writeln(object);
+ }
+ void writeAll(objects, [sep = ""]) {
+ _translation = _FileTranslation.text;
+ _sink.writeAll(objects, sep);
+ }
+ void add(List<int> data) {
+ _translation = _FileTranslation.binary;
+ _sink.add(data);
+ }
void addError(error, [StackTrace stackTrace]) {
_sink.addError(error, stackTrace);
}
- void writeCharCode(int charCode) { _sink.writeCharCode(charCode); }
- Future addStream(Stream<List<int>> stream) => _sink.addStream(stream);
+ void writeCharCode(int charCode) {
+ _translation = _FileTranslation.text;
+ _sink.writeCharCode(charCode);
+ }
+ Future addStream(Stream<List<int>> stream) {
+ _translation = _FileTranslation.binary;
+ return _sink.addStream(stream);
+ }
Future flush() => _sink.flush();
Future close() => _sink.close();
Future get done => _sink.done;
}
+class _StdFileSink extends _StdSinkHelper {
+ // The target of `sink` is expected to be a _StdConsumer.
+ _StdFileSink(IOSink sink) : super(sink, true);
+}
+
+class _StdSocketSink extends _StdSinkHelper {
+ _StdSocketSink(IOSink sink) : super(sink, false);
+}
+
/// The type of object a standard IO stream is attached to.
class StdioType {
static const StdioType TERMINAL = const StdioType._("terminal");
« no previous file with comments | « sdk/lib/io/file_impl.dart ('k') | tests/standalone/io/console_unicode_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698