Link to home
Start Free TrialLog in
Avatar of brucecrabtree
brucecrabtree

asked on

Do I need Chr(10) with Chr(13)?

I'm converting the commas in a list to line breaks (for display in a textarea) this way:

<cfset newlist2 = listChangeDelims(newlist,"#chr(13)#")>

Is it necessary to include chr(10) as well, like this:

<cfset newlist2 = listChangeDelims(newlist,"#chr(10)##chr(13)#")>

When I do that I get double-spaced lines in the textarea, which I'd rather not have.
Avatar of JeffHowden
JeffHowden

It really depends on the OS of the user viewing the textarea.  Just so you know, it's a combination of Chr(13) followed by a Chr(10), not the other way around.  Also, ListChangeDelims() does the very same thing as Replace().  Consider the following:

<cfscript>
  newlist = 'foo,bar,boo,far,goo,car,coo,gar';
  newlist_listchangedelims = ListChangeDelims(newlist, Chr(13) & Chr(10));
  newlist_replace = Replace(newlist, ',', Chr(13) & Chr(10), 'ALL');
</cfscript>
<cfoutput>
  #WriteOutput(newlist_listchangedelims EQ newlist_replace)#
</cfoutput>
Just use the chr(13) and if you get what you want then it is OK.  The line breaks are coming from the extra char(10).
Using just Chr(13) isn't going to get the job done.  Some operating systems need the Chr(10) to display things properly.
ASKER CERTIFIED SOLUTION
Avatar of JeffHowden
JeffHowden

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of brucecrabtree

ASKER

Thanks Jeff. Is Replace() better than listChangeDelims ?
It's not so much that it's better, it's that sometimes it'll yield more consistent results.