View comments | RSS feed
Contents > CFML Reference > ColdFusion Functions > Wrap PreviousNext

Wrap

Wraps text so that each line has a specified maximum number of characters.

String containing the wrapped text.

String functions

Wrap(string, limit[, strip])

cfmail

ColdFusion MX 6.1: Added this function

Parameter

Description

string

String or variable that contains one. The text to wrap.

limit

Positive integer maximum number of characters to allow on a line.

strip

Boolean specifying whether to remove all existing newline and carriage return characters in the input string with spaces before wrapping the text. Default: False.

Inserts line break at the location of the first white space character (such as a space, tab, or new line) before the specified limit on a line. If a line has no whitespace characters before the limit, inserts a line break at the limit. Uses the operating-system specific line break: newline for UNIX, carriage return and newline on Windows.

If you specify the strip parameter, all existing line breaks are removed, so any paragraph formatting is lost.

Use this function to limit the length of text lines, such as text to be included in a mail message. The cfmail and cfmailpart tag wraptext attributes use this function

<h3>Wrap Example</h3>
<cfset inputText="This is an example of a text message that we want to wrap. It is rather long and needs to be broken into shorter lines.">
<cfoutput>#Wrap(inputText, 59)#</cfoutput>

Contents > CFML Reference > ColdFusion Functions > Wrap PreviousNext

ColdFusion 9 | ColdFusion 8 | ColdFusion MX 7 | ColdFusion MX 6.1 | ColdFusion MX | Forums | Developer Center | Bug Reporting

Version 6.1

Comments are no longer accepted for ColdFusion MX 6.1. ColdFusion 8 is the current version.

Comments


ASandstrom said on Sep 7, 2005 at 6:20 AM :
The wrap function does not put <br> tags in the text. Instead, it places line feed characters. As stated above, this function is for use in formatting strings for use in mail messages.

To illustrate how this function works, save the example code in a .cfm file, then browse to the file. The text does not wrap in the display (as this is not what this function is meant to do). However, when you view the source, the text appears as follows:

<h3>Wrap Example</h3>

This is an example of a text message that we want to wrap.
It is rather long and needs to be broken into shorter
lines.

 

RSS feed | Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/coldfusion/6.1/htmldocs/funca119.htm