<div dir="ltr"><div>Thanks to you both!</div><div>Maybe I missed something, but isn't there a way to strip/skip the "line endings"?</div></div><br><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">Em dom., 27 de jul. de 2025 às 09:29, Michael Van Canneyt via fpc-pascal <<a href="mailto:fpc-pascal@lists.freepascal.org">fpc-pascal@lists.freepascal.org</a>> escreveu:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
Hello,<br>
<br>
I have added (long overdue) multiline string support to the FPC compiler.<br>
<br>
It is activated by default in objfpc and delphi modes.<br>
<br>
if you wish to use it (or disable it), there is a modeswitch:<br>
<br>
{$modeswitch multilinestrings}<br>
or, to disable<br>
{$modeswitch multilinestrings-}<br>
<br>
Due to historic reasons, it comes in 2 flavours.<br>
<br>
Delphi style:<br>
<br>
a multiline string starts with a odd number of quotes (3 at least), <br>
followed by a newline, and ends with an equal amount of quotes on a <br>
line preceded by only whitespace:<br>
<br>
const s = '''<br>
some<br>
multiline<br>
stuff<br>
''';<br>
<br>
In the resulting string, the first N whitespace characters will be trimmed,<br>
where N is the number of whitespace characters before the terminating<br>
quotes. The last CR/LF is also stripped. If a line contains less whitespaces<br>
than the final line, it is considered an error.<br>
<br>
So the above example would be equivalent to<br>
<br>
const s = 'some '+sLineBreak+'multiline '+sLinebreak+'stuff';<br>
<br>
(the "some " and "multiline " are followed by a space, your mail client may not<br>
display that corectly in the source... )<br>
<br>
The line-ending in the resulting string is by default the native line ending.<br>
this can be influenced by the (delphi-compatible) directive:<br>
<br>
{$TEXTBLOCK NATIVE/CR/LF/CRLF}<br>
<br>
To include triple quotes in such a string, you can use 5 quotes to delimit<br>
the string:<br>
<br>
const s = '''''<br>
some<br>
'''multiline '''<br>
stuff<br>
''''';<br>
<br>
All this is Delphi compatible.<br>
<br>
The FPC bugtracker contains since a long time a proposal for multiline<br>
strings using a backtick as the quote character:<br>
<br>
<a href="https://gitlab.com/freepascal.org/fpc/source/-/issues/35827" rel="noreferrer" target="_blank">https://gitlab.com/freepascal.org/fpc/source/-/issues/35827</a><br>
<br>
This has since been implemented in pas2js (our pascal to Javascript transpiler). <br>
In the interest of compatibility, that proposal has also been implemented in<br>
FPC as well.<br>
<br>
In fact, the implementation in the issue has served as the start of the Delphi-compatible<br>
implementation.<br>
<br>
This means you can also do<br>
<br>
const S = `some<br>
multiline<br>
stuff`;<br>
<br>
This form of multiline strings can be configured using 2 directives:<br>
<br>
{$MULTILINESTRINGTRIMLEFT N}<br>
<br>
where N is the number of whitespace characters to strip from the string.<br>
<br>
The line ending can be set using<br>
<br>
{$MULTILINESTRINGLINEENDING PLATFORM/CR/LF/CRLF/SOURCE}<br>
<br>
SOURCE will use the line ending as used in the string definition, other than<br>
that the effect is identical to $TEXTBLOCK.<br>
<br>
Despite the large amount of tests for this new feature, there may still be bugs,<br>
please report them in the bugtracker if you encounter them.<br>
<br>
My thanks to user Akira1364 (real name?) for the initial implementation of<br>
this feature.<br>
<br>
Michael.<br>
_______________________________________________<br>
fpc-pascal maillist - <a href="mailto:fpc-pascal@lists.freepascal.org" target="_blank">fpc-pascal@lists.freepascal.org</a><br>
<a href="https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal" rel="noreferrer" target="_blank">https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal</a><br>
</blockquote></div>