[phobos] std.stdio: text and binary modes on Windows
Walter Bright
walter at digitalmars.com
Thu May 27 14:34:38 PDT 2010
I agree that rawWrite should always write in binary mode.
Shin Fujishiro wrote:
> Should File.rawWrite() write data to file in binary mode? Or should it
> just transparently call fwrite() as documented?
>
> I saw a D user who had trouble writing binary data to stdout on Windows.
> Every occurrence of 0x0A was translated to 0x0D 0x0A even he used
> stdout.rawWrite() -- because stdout was opened in text mode.
>
> Try this:
> --------------------
> import std.stdio;
> void main()
> {
> ubyte[] data = [ 0x9, 0xA, 0xB ];
> stdout.rawWrite(data);
> }
> --------------------
> On Windows, this program writes [ 0x9, 0xD, 0xA, 0xB ].
>
> I think File.rawWrite() should always write data in binary mode
> regardless of which mode is set.
>
> What do you think?
>
>
> Shin
> _______________________________________________
> phobos mailing list
> phobos at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/phobos
>
>
>
More information about the phobos
mailing list