[Lazarus] Garbage writing to console

Ondrej Pokorny lazarus at kluug.net
Thu Feb 22 22:26:56 CET 2018


On 22.02.2018 12:21, Luca Olivetti via Lazarus wrote:
> Lazarus 1.8.0, fpc 3.0.4, windows application (with "win32 gui 
> application unchecked") or console application (using LazUTF8).
> File encoding utf-8 without bom.
>
> writeln('áéí')
>
> produces garbage, contrary to what's said in 
> http://wiki.freepascal.org/Unicode_Support_in_Lazarus#Writing_to_console

No, it's not contrary - just the opposite. The problem is that áéí (ANSI 
1250 or whatever) have different codes to your console codepage (CP437 
or whatever). You should open/edit your program source code in your 
console codepage - you obviously edit it in ANSI.

> The strange thing is that:
>
> procedure w(const s:string);
> begin
>   writeln(s);
> end;
>
> w('áéí')
>
> also gives the correct output.

It looks like writeln ignores the codepage for constant strings but 
checks it for "normal" strings. You should ask on fpc-devel list for 
details.

Ondrej


More information about the Lazarus mailing list