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

Issue 2698813002: [dart:io][windows] Make unicode characters display correctly. (Closed)

Created:
3 years, 10 months ago by zra
Modified:
3 years, 10 months ago
Reviewers:
Florian Schneider, siva
CC:
reviews_dartlang.org, vm-dev_dartlang.org
Target Ref:
refs/heads/master
Visibility:
Public.

Description

[dart:io][windows] Make unicode characters display correctly. This change has two pieces. - Set the console code page to UTF8. - This makes strings printed with print() display correctly - Set the file translation mode to _O_WTEXT when writing to a stdout or stderr that is connected to a console. - This makes strings printed with e.g. stdout.writeln() display correctly. fixes #28571 R=asiva@google.com, fschneider@google.com Committed: https://github.com/dart-lang/sdk/commit/bc079538666c5a9b1fff2f4848baf2ddef985932

Patch Set 1 #

Patch Set 2 : Use _setmode correctly #

Patch Set 3 : Remove setting translation mode from the Dart API #

Patch Set 4 : Work on making tests pass #

Patch Set 5 : Cleanup. Formatting. #

Patch Set 6 : Make tests pass #

Total comments: 10

Patch Set 7 : Address comments #

Patch Set 8 : Address comments #

Unified diffs Side-by-side diffs Delta from patch set Stats (+301 lines, -22 lines) Patch
M runtime/bin/file.h View 1 2 3 4 2 chunks +11 lines, -0 lines 0 comments Download
M runtime/bin/file.cc View 1 2 3 4 5 6 7 1 chunk +16 lines, -0 lines 0 comments Download
M runtime/bin/file_android.cc View 1 2 3 4 5 6 7 1 chunk +5 lines, -0 lines 0 comments Download
M runtime/bin/file_fuchsia.cc View 1 2 3 4 5 6 7 1 chunk +5 lines, -0 lines 0 comments Download
M runtime/bin/file_linux.cc View 1 2 3 4 5 6 7 1 chunk +5 lines, -0 lines 0 comments Download
M runtime/bin/file_macos.cc View 1 2 3 4 5 6 7 1 chunk +5 lines, -0 lines 0 comments Download
M runtime/bin/file_patch.dart View 1 chunk +1 line, -0 lines 0 comments Download
M runtime/bin/file_unsupported.cc View 1 chunk +6 lines, -0 lines 0 comments Download
M runtime/bin/file_win.cc View 1 2 3 4 5 6 7 5 chunks +87 lines, -11 lines 0 comments Download
M runtime/bin/io_natives.cc View 1 chunk +1 line, -0 lines 0 comments Download
M runtime/bin/platform_win.cc View 1 2 3 4 5 6 3 chunks +39 lines, -0 lines 0 comments Download
M runtime/bin/process_patch.dart View 1 2 3 4 5 2 chunks +2 lines, -2 lines 0 comments Download
M runtime/bin/run_vm_tests.cc View 1 2 3 4 5 6 1 chunk +5 lines, -0 lines 0 comments Download
M runtime/bin/utils_win.h View 1 chunk +9 lines, -0 lines 0 comments Download
M sdk/lib/io/file_impl.dart View 1 2 3 4 5 3 chunks +29 lines, -0 lines 0 comments Download
M sdk/lib/io/stdio.dart View 1 2 3 4 5 2 chunks +44 lines, -9 lines 0 comments Download
A tests/standalone/io/console_unicode_test.dart View 1 2 3 4 5 6 7 1 chunk +31 lines, -0 lines 0 comments Download

Messages

Total messages: 12 (3 generated)
zra
3 years, 10 months ago (2017-02-17 16:37:49 UTC) #3
Florian Schneider
Thanks for fixing this! Lgtm w/ comment. https://codereview.chromium.org/2698813002/diff/100001/runtime/bin/file_win.cc File runtime/bin/file_win.cc (right): https://codereview.chromium.org/2698813002/diff/100001/runtime/bin/file_win.cc#newcode45 runtime/bin/file_win.cc:45: void set_binary(bool ...
3 years, 10 months ago (2017-02-21 20:34:51 UTC) #4
zra
https://codereview.chromium.org/2698813002/diff/100001/runtime/bin/file_win.cc File runtime/bin/file_win.cc (right): https://codereview.chromium.org/2698813002/diff/100001/runtime/bin/file_win.cc#newcode45 runtime/bin/file_win.cc:45: void set_binary(bool binary) { On 2017/02/21 20:34:50, Florian Schneider ...
3 years, 10 months ago (2017-02-21 21:26:46 UTC) #5
Florian Schneider
lgtm
3 years, 10 months ago (2017-02-21 21:42:25 UTC) #6
siva
lgtm with comments. Can a test be added to verify this? https://codereview.chromium.org/2698813002/diff/100001/runtime/bin/file.cc File runtime/bin/file.cc (right): ...
3 years, 10 months ago (2017-02-22 00:58:45 UTC) #7
zra
The new behavior is only triggered when stdout and stderr are attached to a tty, ...
3 years, 10 months ago (2017-02-22 05:07:16 UTC) #8
zra
Committed patchset #8 (id:140001) manually as bc079538666c5a9b1fff2f4848baf2ddef985932 (presubmit successful).
3 years, 10 months ago (2017-02-22 06:47:09 UTC) #10
ahe
On 2017/02/22 05:07:16, zra wrote: > The new behavior is only triggered when stdout and ...
3 years, 10 months ago (2017-02-23 10:01:43 UTC) #11
ahe
3 years, 10 months ago (2017-02-23 10:08:36 UTC) #12
Message was sent while issue was closed.
On 2017/02/23 10:01:43, ahe wrote:
> On 2017/02/22 05:07:16, zra wrote:
> > The new behavior is only triggered when stdout and stderr are attached to a
> tty,
> > so we can't test from within our test harness, but I've added a test that
> passes
> > utf8 strings to print, stdout.writeln, and stdout.add as a sanity check
since
> I
> > couldn't find an existing one.
> 
> I don't think the test works correctly on Android, and breaks the test runner.
> 
> Also, running something attached to a tty on Windows must mean running it
inside
> cmd.exe. That's possible by writing a test that launches cmd.exe as an
external
> process and tells cmd.exe to run dart.exe given a script that triggers the
> desired behavior.
> 
> More details are available here:
> https://technet.microsoft.com/en-us/library/cc771320(v=ws.11).aspx

When I run this:

./xcodebuild/ReleaseX64/dart tests/standalone/io/console_unicode_test.dart |
iconv -t utf8 -f utf8

I see this:

These are three black spades: ♠♠♠
German characters: aäbcdefghijklmnoöpqrsßtuüvwxyz
These are three black spades: ♠♠♠
German characters: aäbcdefghijklmnoöpqrsßtuüvwxyz
These are three black spades: ```
German characters: a
iconv: (stdin):6:20: cannot convert

Powered by Google App Engine
This is Rietveld 408576698