Skip to content

on Windows, stdout isn't set to binary anymore #22471

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
DartBot opened this issue Feb 18, 2015 · 6 comments
Closed

on Windows, stdout isn't set to binary anymore #22471

DartBot opened this issue Feb 18, 2015 · 6 comments
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. closed-duplicate Closed in favor of an existing report library-io

Comments

@DartBot
Copy link

DartBot commented Feb 18, 2015

This issue was originally filed by [email protected]


This is a regression. Up to 1.2.0, this was fine. It's broken since 1.3.0.

Example:

    import 'dart:io';
    main(){
      stdout.writeCharCode(0x0A); // \n
    }

Piped to a file like this:

    dart foo.dart > bar.txt

Results in a file which contains these two bytes (\r\n):

    0x0D 0x0A

With 1.2.0, you only got the 0x0A (\n) byte.

stdout should be set to binary like it was before and like it is with, say, Java. If it's set to text, writing binary contents to stdout will not work properly on Windows.

@DartBot
Copy link
Author

DartBot commented Feb 18, 2015

This comment was originally written by @Fox32


Interesting, this could also be the cause for the protobuf plugin problems that I experience on versions newer than 1.2. The problem only occures on Windows and the output also contains "\r\n", mabye protoc doesn't like that.

See also dart-archive/dart-protoc-plugin#25

@DartBot
Copy link
Author

DartBot commented Feb 18, 2015

This comment was originally written by @seaneagan


Text mode is probably the right default, but binary mode should be allowed as well, so I think this should be merged with issue #19334.

@DartBot
Copy link
Author

DartBot commented Feb 18, 2015

This comment was originally written by @seaneagan


Note that there has not been any comment on issue #19334 yet, maybe someone can be cc'd?

@DartBot
Copy link
Author

DartBot commented Feb 19, 2015

This comment was originally written by [email protected]


Text mode is probably the right default

As far as I can tell, the only advantage of text mode is that the output, if redirected to a file, can be properly viewed in Notepad.

\n works just fine in the console or virtually any other editor. Even edit.com (the DOS program) was perfectly fine with \n.

Try this Java program:

    class Bla {
      public static void main(String[] args) {
        System.out.print("foo");
        System.out.write(0x0A);
        System.out.print("bar");
      }
    }

It outputs these 7 bytes:

    66 6F 6F 0A 62 61 72

Which are displayed like:

    foo
    bar

Anyhow, if you really want \r\n, you can just output \r\n. Binary mode lets you do that.

@kasperl
Copy link

kasperl commented Feb 19, 2015

cc @sgjesse.
Added Area-Library, Library-IO, Triaged labels.

@nex3
Copy link
Member

nex3 commented Apr 23, 2015

Added Duplicate label.
Marked as being merged into #19334.

@DartBot DartBot added Type-Defect area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. library-io closed-duplicate Closed in favor of an existing report labels Apr 23, 2015
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. closed-duplicate Closed in favor of an existing report library-io
Projects
None yet
Development

No branches or pull requests

4 participants