Escape codes are not 100% portable

Jens Bauer via Digitalmars-d digitalmars-d at puremagic.com
Thu Apr 2 05:57:11 PDT 2015


> Which compilers?

MrCpp, MrC, MPWC, MPWCpp and CodeWarrior.

These compilers must respect the platform's definition of \n = 
newline and \r = carriage return.
Because the platform defines newline = 13, then \n must have the 
value 13.

Since there's not clear definition of \n and \r, they can't be 
trusted.
As the hex values will not change, I would think that this is a 
safer bet.

Also ... some compilers might expand \n to a two-byte value 
0x0d0a; I've seen this as well, but it's been a while, so I do 
not remember which compiler that did this (obviously, it's one, 
which would run on a DOS-like environment).


More information about the Digitalmars-d mailing list