I wonder if this is intended - writing e.g. log files on windows would potentially need special handling for newline characters, as println behaves the same.
It behaves the same. I noticed that behaviour a while back while writing a small tool which also logs stuff (the logs ended up not being used, ironically - but at least the capability is there).
julia> let io = IOBuffer()
println(io, "foo")
String(take!(io))
end
"foo\n"
I guess it comes down to whether Base or each individual developer should make the decision on how to print this based on the platform. There’s good arguments either way. Personally, I lean more towards one single implementation to avoid as many differences between platforms as possible. Although I do like the concept of a true carriage return (EDIT: after some testing, carriage return works on either platform anyway).
I have not formed an opinion on whether this is the desired way, I was just asking because I am curious how newlines are meant to be handled cross-platform.
Does the \n not cause a problem on Windows when using the terminal? Or is it somehow converted?
C:\Users\<snip>>julia -e println(\"test\ntest\")
test
test
I do seem to recall some change to ConsoleHost a while back where support for this was added - since WSL (Windos Subsystem for Linux, the Linux shell thing on Windows) came into existence, they’ve added a bunch of Unix support to Windows. Some programs like Notepad are still lagging behind a bit, but even they are getting updated with, I think, the coming september update.