www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - CRLF in wysiwyg string literals?

reply Lionello Lunesu <lionello lunesu.remove.com> writes:
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.
May 11 2016
parent reply Kagamin <spam here.lot> writes:
For HTTP you can't use anything but escape sequences. AFAIK, they 
apply only to protocol headers, the content can be anything.
May 12 2016
parent Lionello Lunesu <lionello lunesu.remove.com> writes:
On 12/5/2016 16:38, Kagamin wrote:
 For HTTP you can't use anything but escape sequences. AFAIK, they apply
 only to protocol headers, the content can be anything.
Not just HTTP, MIME multipart/mixed content also requires CRLF, as does application/http content.
May 12 2016