最近看fpcsrc(fpc trunk-3.3.1)源码发现freepascal已支持多行字符串,默认是禁用的,如要启用多行字符串用:
{$$modeswitch MULTILINESTRINGS}
多行字符串前后用`
s:String=`freepascal多行字符测试还真行的哦`;
完整测试代码:
unit Unit1;{$mode objfpc}{$H+} {$$modeswitch MULTILINESTRINGS} interfaceusesClasses, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls;type{ TForm1 }TForm1 = class(TForm)Memo1: TMemo;procedure FormCreate(Sender: TObject);privatepublicend;varForm1: TForm1;s:String=`freepascal多行字符测试还真行的哦`; implementation{$R *.lfm}{ TForm1 }procedure TForm1.FormCreate(Sender: TObject); beginMemo1.Lines.Add(s); end;end.

如果加:
{$MultiLineStringTrimLeft auto} //消除左边空格
s:String=`freepascal多行字符测试还真行的哦`;

