System.SysUtils.WrapText

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

function WrapText(const Line, BreakStr: string; const BreakChars: TSysCharSet; MaxCol: Integer): string;
function WrapText(const Line: string; MaxCol: Integer): string;

C++

extern DELPHI_PACKAGE System::UnicodeString __fastcall WrapText(const System::UnicodeString Line, const System::UnicodeString BreakStr, const TSysCharSet &BreakChars, int MaxCol)/* overload */;

Properties

Type Visibility Source Unit Parent
function public
System.SysUtils.pas
System.SysUtils.hpp
System.SysUtils System.SysUtils

Description

Inserts a line break into a string as its length approaches a specified size.

WrapText does not insert a break into an embedded quoted string (both single and double quotation marks are supported).

Commonly, the WrapText routine searches for space, hyphen, or tab characters where to break the line and inserts a carriage return/line feed pair on Windows, or a linefeed on MacOS, before counting MaxCol characters (first overload).

The second overload will insert a new string sequence (specified by the BreakStr parameter) at the last occurrence of any of the break characters specified in the BreakChars set parameter, before counting MaxCol characters.

For instance, after running the following code

WrapText('The rain in Spain falls mainly on the plain.', #13#10, ['.',' ',#9,'-'], 15);
TSysCharSet bChars;
bChars << '.' << ' ' << '/t' << '-';
WrapText("The rain in Spain falls mainly on the plain.", "/n", bChars, 15);

the result will be:

The rain in Spain
falls mainly on the
plain.

See Also