• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1408
  • Last Modified:

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.
0
brucecrabtree
Asked:
brucecrabtree
  • 4
1 Solution
 
JeffHowdenCommented:
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>
0
 
wytcomCommented:
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).
0
 
JeffHowdenCommented:
Using just Chr(13) isn't going to get the job done.  Some operating systems need the Chr(10) to display things properly.
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

 
JeffHowdenCommented:
In fact, the extra line break is because of the incorrect sequence of Chr(10) Chr(13) when it *should* be Chr(13) Chr(10).
0
 
brucecrabtreeAuthor Commented:
Thanks Jeff. Is Replace() better than listChangeDelims ?
0
 
JeffHowdenCommented:
It's not so much that it's better, it's that sometimes it'll yield more consistent results.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now