[Lazarus] Garbage writing to console
Mattias Gaertner
nc-gaertnma at netcologne.de
Fri Feb 23 11:18:55 CET 2018
On Fri, 23 Feb 2018 10:56:11 +0100
Luca Olivetti via Lazarus <lazarus at lists.lazarus-ide.org> wrote:
> El 23/02/18 a les 09:23, Mattias Gaertner via Lazarus ha escrit:
> > On Fri, 23 Feb 2018 08:56:55 +0100
> > Ondrej Pokorny via Lazarus <lazarus at lists.lazarus-ide.org> wrote:
> >
> >> On 23.02.2018 8:46, Mattias Gaertner via Lazarus wrote:
> >>> But this is a Lazarus issue.
> >>
> >> Why?
> >
> > Because the wiki page is unclear.
> >
> > writeln('áéí'); // works only with source codepage UTF-8
>
> That's not enough, it has to be either utf8 with BOM or with {$codepage
> utf8}
> (Which has its own set of problems)
"source codepage UTF-8" = "utf8 with BOM" = "{$codepage UTF8}" =
"-Fcutf8"
> > s:='áéí';
> > writeln(s); // works with and without
>
> Correct, but I don't understand why
>
> >
> > writeln(UTF8ToConsole('áéí')); // works with and without
>
> Yes, that works too.
Write and Writeln are pure compiler magic.
Apparently if the string is CP_ACP, it is passed unchanged to Output,
ignoring the DefaultSystemCodepage variable. Otherwise it converts the
string to the console codepage. This allows to write arbitrary bytes.
Maybe some compiler guru can confirm this.
Mattias
More information about the Lazarus
mailing list