[Lazarus] FPC 2.7.1 and console output
Mattias Gaertner
nc-gaertnma at netcologne.de
Thu Dec 4 11:39:54 CET 2014
On Thu, 04 Dec 2014 07:00:59 +0100
Hans-Peter Diettrich <DrDiettrich1 at aol.com> wrote:
>[...]
> I included the code (readable by everybody), didn't transmit an file.
> Also UTF8ToConsole seems not to exist any more in FPC 2.7.1, and should
> not be required any more.
> So I'm not sure what you mean :-(
UTF8Console is needed, when your source is UTF-8, but the compiler
thinks it is Windows CP. UTF8Console is defined in LazUTF8.
An alternative is UTF8Decode.
> Just tested on WinXP:
>
> program test;
> var a: AnsiString;
> begin
> a := 'äöü';
> WriteLn(a,'äöü');
> end;
>
> works differently with file encoding Ansi, UTF-8 and UTF-8bom. The
> latter correctly shows 'äöüäöü', else a mix of several encodings shows
> up in the console.
I see. Indeed I never tried passing a constant in writeln.
Does Delphi also pass constants unconverted to writeln?
> Using the default Lazarus file encoding (UTF-8 without BOM) requires to
> add {$codepage UTF8}, to make the program (hopefully) work on either
> platform.
Well, it only works on platforms with 'äöü' in their console codepage.
> {$codepage UTF8} requires UTF-8 file encoding as well, doesn't
> compile when stored as Ansi.
What do you mean with "doesn't compile"? What compiler error?
> Adding SysUtils, and AnsiUpperCase for the WriteLn arguments, correctly
> shows 'ÄÖÜÄÖÜ' in Ansi file encoding, but 'äöüäöü' in UTF8bom encoding,
> garbage with UTF-8 file encoding, and again 'äöüäöü' with added
> {$codepage UTF8}.
Thanks. Confirmed.
I will add AnsiUpperCase to the list.
>[...]
Mattias
More information about the Lazarus
mailing list