www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Why std.file.append() new lind "\n" not work in Windows?

reply Marcone <marcone email.com> writes:
std.file.append("file; \nApple");
std.file.append("file; \nBanana");

Result:

AppleBanana
Jun 09 2021
next sibling parent reply Marcone <marcone email.com> writes:
std.file.append(file; "\nApple");
std.file.append(file; "\nBanana");

Result:

AppleBanana
Jun 09 2021
parent reply Marcone <marcone email.com> writes:
std.file.append(file, "\nApple");
std.file.append(file, "\nBanana");

Result:

AppleBanana
Jun 09 2021
parent nov <sorryno em.ail> writes:
On Wednesday, 9 June 2021 at 21:12:46 UTC, Marcone wrote:
 Result:

 AppleBanana
open with wordpad or open with notepad++ or display with "type filename" command
Jun 09 2021
prev sibling parent tsbockman <thomas.bockman gmail.com> writes:
On Wednesday, 9 June 2021 at 21:10:58 UTC, Marcone wrote:
 std.file.append("file; \nApple");
 std.file.append("file; \nBanana");

 Result:

 AppleBanana
Not all systems use the same char sequence for line breaks. In particular, Microsoft Windows uses "\r\n". You can use [`std.ascii.newline`](https://dlang.org/phobos/std_ascii.html#newline) to write platform-independent code. Functions like `std.stdio.writeln` that write a newline at the end of the message will also do the right thing.
Jun 09 2021