File.write introduces \r regardless of presence

HuskyNator HuskyNator at protonmail.ch
Sat Jul 16 19:54:08 UTC 2022


While trying to figure out why my reading from & write back to 
file kept increasing the size of my entries, I figured out 
File.write always introduces a \r character before any \n 
characters, even if they are already preceded by one.

Is this intentional behaviour or an oversight?

Example:
```d
module app;
import std.stdio;
import std.file;

void main(string[] args) {
	string a = "`a\r\n\r\nb`\r\n";
	File("test.txt", "w").write(a);
}
```

Content of text.txt:
```
`a\r\r\n\r\r\nb\`\r\r\n
```


More information about the Digitalmars-d-learn mailing list