www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - operating-system-specific line ending

reply sai <sai_member pathlink.com> writes:
how to know what is the operating-system-specific line ending ?

std.stream has following code:
----------------------
void writeLine(char[] s) {
writeString(s);
version (Win32)
writeString("\r\n");
else version (Mac)
writeString("\r");
else
writeString("\n");
}
----------------------


how about making it
----------------------

version (Win32)
conts _D_NL = "\r\n"; 
else version (Mac)
conts _D_NL = "\r";
else
conts _D_NL = "\n";

void writeLine(char[] s) {
writeString(s);
writeString(_D_NL);
}
----------------------

so that we can use the constant _D_NL directly in our programs. 

May be such a constant is already defined somewhere, if so, could somebody
please point it to me ?

thanks in advance
-SAI
Dec 05 2005
parent "Chris Miller" <chris dprogramming.com> writes:
On Mon, 05 Dec 2005 18:07:20 -0500, sai <sai_member pathlink.com> wrote:

 how to know what is the operating-system-specific line ending ?
std.path.linesep Why it's there, I don't know.
Dec 05 2005