System.SysUtils.WrapText
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 */;
プロパティ
種類 | 可視性 | ソース | ユニット | 親 |
---|---|---|---|---|
function | public | System.SysUtils.pas System.SysUtils.hpp |
System.SysUtils | System.SysUtils |
説明
文字列の長さが指定のサイズに近づくたびに、文字列に改行を挿入します。
通常、WrapText ルーチンでは、MaxCol
で指定された文字数に達する前に、改行位置となるスペース、ハイフン、タブ文字のいずれかを探し、Windows の場合は復帰/改行ペアを、MacOS の場合は改行を、それぞれ挿入します(第 1 のオーバーロード関数)。
第 2 のオーバーロード関数では、MaxCol
で指定された文字数に達する前に、BreakChars
セット パラメータで指定された改行文字のいずれかが最後に現れた位置に新しい文字列シーケンス(BreakStr
パラメータで指定されたもの)を挿入します。
たとえば、以下のコードを実行すると、
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 rain in Spain falls mainly on the plain.