According to the docs Wrap() uses the OS line separator which is different
on Unix/Mac and Windows. That might cause an issue because for unix it only
looks for \n but on windows it is probably looking for a \r\n.

So if you are on windows, and your example text only used \n to break lines,
then it would produce the results you got.

Try passing a true into the third argument to strip out existing new line
chars, or you might need to find / write a UDF if you want to preserve
existing line breaks.

Pete Freitag
http://foundeo.com/ - ColdFusion Consulting & Products
http://petefreitag.com/ - My Blog
http://hackmycf.com - Is your ColdFusion Server Secure?


On Tue, Nov 9, 2010 at 12:32 PM, Eric Roberts <
[email protected]> wrote:

>
> I am trying to use the cf wrap function and I am getting some odd results.
> Here is the text (entered in a text area...the line breaks shown are from
> hitting the enter key)
>
> Life is but a stopping place,
> A pause in what's to be.
> A resting place along the road,
> To sweet eternity.
>
> Here is the results of the text string after it is wrapped and put into an
> array.  Why would A be in a single line instead of part of the contents of
> line three and also notice the odd breaks with 4,5,6, and 7
>
> array
> 1     Life is but a stopping place,
> 2     A
> 3     pause in what's to be.
> 4     A resting
> 5     place along the road,
> 6     To sweet
> 7     eternity.
>
> Should look like
> 1. Life is but a stopping place,
> 2. A pause in what's to be.
> 3. A resting place along the road,
> 4  To sweet eternity.
>
> here is the code that accomplishes the above.  Arguments.char_count=34 int
> his case.
>
> <cfset variables.text.txtWrapped=wrap(variables.text.string,
> arguments.char_count)>
>        <cfset nol=listlen(variables.text.txtWrapped,"#chr(10)#")>
>        <cfset variables.text.txtLines=arrayNew(1)>
>        <cfloop from="1" to="#nol#" step="1" index="x">
>            <cfset variables.text.txtLines[x]="
> "&listgetat(variables.text.txtWrapped,x,"#chr(10)#")>
>        </cfloop>
>
> Any ideas as to what i am doing wrong?
>
>
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:339085
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm

Reply via email to