www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - File.write write extra CR character if a string has CRLF on windows

reply Pham <home home.com> writes:
string s is multi-lines (CRLF as line break)
The write function will write extra CR character for each CRLF 
pair -> why (bug?)

import std.file;
import std.stdio;

string s = ...;

auto fHandle = File("f:\\text.txt", "w"); // open for writing
fHandle.write(s);
fHandle.close();
Oct 06 2016
parent Rene Zwanenburg <renezwanenburg gmail.com> writes:
On Thursday, 6 October 2016 at 15:00:00 UTC, Pham wrote:
 string s is multi-lines (CRLF as line break)
 The write function will write extra CR character for each CRLF 
 pair -> why (bug?)

 import std.file;
 import std.stdio;

 string s = ...;

 auto fHandle = File("f:\\text.txt", "w"); // open for writing
 fHandle.write(s);
 fHandle.close();
Take a look at this thread: http://forum.dlang.org/post/ehdnboaufaadgiaahldb forum.dlang.org
Oct 06 2016