Currently I'm putting newlines in strings through one of these two methods:
<cfset someStr="This is line 1" & Chr(10) & "This is line 2" & Chr(10) & "This is line 3" />
OR
<cfset NL=Chr(10) />
<cfset someStr="This is line 1#NL#This is line 2#NL#This is line 3" />
Is there anything more like the Java/C++ way? Something more like this I mean:
<cfset someStr="This is line 1\nThis is line 2\nThis is line 3" />
CF8 formatted cfmail with line feeds and without adding anything. Seems like Adobe would provide something SPECIFIC about "why" and a simple work-around. ... Jurisdictionary
Not directly in CF, I'll leave it to the CF-Java dudes to say whether you can use a Java method directly on a CF var to achieve what you want, but...
You could use cfsavecontent to put natural line breaks in:
Then check it with:
Note that the Trim() is there to get rid of the first and last line breaks if you don't want them.
I was looking for a way to output a new line in
<cfscript>
, so I figured I'd leave my answer for anyone else who arrived in a similar fashion:writeOutput
appends to the page-output stream as html, so you need to write html for it to output (this means you can also include
to add spaces for indentation).Your way is correct. There is no support for \n or \r in CF. From the Live Docs
i use this:
If you are into platform-independent development, you can do:
For example, in your
application.cfm/cfc
or somewhere else high-level and use that.