CRLF in wysiwyg string literals?

Lionello Lunesu via Digitalmars-d digitalmars-d at puremagic.com
Wed May 11 19:33:39 PDT 2016


Writing a lot of server side D code lately, and bummed the usual `string 
literals` (or r"string literals") will only use '\n' as the End of line 
character, while HTTP (and others too) use CRLF for EOL.

One way is to create a CTFE function that replaces all \n with \r\n, and 
call this on all string literals.

Another idea I just had was to reserve the rn prefix for such strings, 
ie. rn"This string
uses CRLF new lines."

The rn prefix would reflect the usual \r\n CRLF pairs. (Perhaps 
confusing, since the r doesn't actual mean CR, and there's no n prefix 
either.)

Just a thought. How have others solved this? Short of using \r\n\r\n, 
that is.

L.


More information about the Digitalmars-d mailing list