Skip to content
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

Mostly portable way to set stdout/stdin mode #9988

Open
dlangBugzillaToGithub opened this issue Jul 4, 2013 · 0 comments
Open

Mostly portable way to set stdout/stdin mode #9988

dlangBugzillaToGithub opened this issue Jul 4, 2013 · 0 comments

Comments

@dlangBugzillaToGithub
Copy link

bearophile_hugs reported this on 2013-07-04T17:25:52Z

Transfered from https://issues.dlang.org/show_bug.cgi?id=10545

Description

In Phobos I'd like a (portable across different operating systems) way to set the mode of stdout/stdin (to binary or text mode).


A not portable way to do in C on Windows is:

setmode(fileno(stdout), O_BINARY);


In Python a not portable way to do it is (works on Windows):

import os, msvcrt
msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY)


I think an almost portable way to do it is (this is a C99 version of freopen):

freopen(null, "wb", stdout);
@LightBender LightBender removed the P4 label Dec 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants