On Wednesday, 19 June 2013 at 19:14:58 UTC, Roger Stokes wrote:
and got this compiler diagnostic:

Oh, I thought you were writing to a socket. Yeah, to a different thread, D will complain if you don't make a sharable copy. So you do want to idup it...


[47, 47, 32, 101, 120, 97, ....

....
The numbers 47, 47, 32, etc look like the ASCII indexes of the characters
which should be in the output,  not the characters themselves!


The reason here is this line:
      stdout.write(buffer);

The write function changes the format based on the type of input. Since the input here is a ubyte[], it doesn't realize it is a printable string and prints the numeric values of a byte array instead.

Try stdout.write(cast(string) buffer)) and you should get what you expect. Another potential change would be to use stdin.byLine instead of stdin.byChunk. byLine returns char[], one line at a time, but it cuts off the newline character (if I remember correctly) and can complain if the input isn't valid UTF-8, so it wouldn't work right for a generic file copy function.

Reply via email to