Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trycf/3507ed975dfe5aff36eaf2993aff2e8a to your computer and use it in GitHub Desktop.
Save trycf/3507ed975dfe5aff36eaf2993aff2e8a to your computer and use it in GitHub Desktop.
TryCF Gist
<cfscript>
// Just a new line.
x="
";
// This shows only chr(10) for both Lucee and ACF
writeoutput( "pre-serialize char: ") ;
for ( j=1;j<=len(x);j++) {
writeoutput( x.right(j).asc() & " " ) ;
}
writeoutput("<br>");
// Serialize x to JSON
y=serializeJSON(x);
// Which gives us:
writeoutput("serialized= " & y & "<br>");
//Now deserialize to see what characters are there:
z = deserializeJSON(y) ;
// What characters are there?
writeoutput( "post-serialize char: " ) ;
for ( i=1;i<=len(z);i++) {
writeoutput( z.right(i).asc() & " " ) ;
}
/* LUCEE 5
pre-serialize char: 10 13
serialized= "\r\n"
post-serialize char: 10 13
*/
/* ACF 11+
pre-serialize char: 10
serialized= "\n"
post-serialize char: 10
*/
/*
Lucee: newLine() == \n
*/
</cfscript>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment