[fpc-devel] fpc compiler wrong encoding in console output on Windows

Tomas Hajny XHajT03 at hajny.biz
Wed Aug 30 12:04:41 CEST 2023


On 2023-08-28 15:53, Ondrej Pokorny via fpc-devel wrote:


Hello Ondrej,

> when compiling a program with fpc on Windows, fpc seems to have the
> console output encoding wrong.
> 
> Example program (I am using "ä" because I am on german OS, so "ä" is
> in my DOS Latin and also in my ANSI codepage):
> 
> {$codepage utf8}
> program TestNote;
> begin
> {$note ä}
> end.
> 
> The console output is:
> 
> Free Pascal Compiler version 3.3.1 [2023/08/21] for i386
> Copyright (c) 1993-2023 by Florian Klaempfl and others
> (1002) Target OS: Win32 for i386
> (3104) Compiling TestNote.lpr
> p:\programs\_zk\TestNote\TestNote.lpr(6,2) Note: (2025) User defined: 
> ä
> (9015) Linking 
> P:\programs\_zk\TestNote\lib\Debug\i386-win32\TestNote.exe
> (1008) 8 lines compiled, 0.1 sec, 78736 bytes code, 2148 bytes data
> (1022) 2 hint(s) issued
> (1023) 1 note(s) issued
> 
> So it looks like the FPC compiler output is raw utf-8 instead of DOS
> Latin codepage. Is this wanted?
  .
  .

Your output is different from mine (using a freshly compiled trunk 
compiler):

Free Pascal Compiler version 3.3.1 [2023/08/29] for i386
Copyright (c) 1993-2023 by Florian Klaempfl and others
Target OS: Win32 for i386
Compiling t2.pas
t2.pas(4,2) Note: User defined: ä
Linking t2.exe
5 lines compiled, 0.0 sec, 38160 bytes code, 1412 bytes data
1 note(s) issued


However, I run the compiler from regular command line, not from Lazarus. 
What do you get when running the following test program (you can 
simulate the same conditions e.g. by naming the resulting binary fpc.exe 
and configuring Lazarus to use this "compiler"):

uses
  Windows;
begin
  WriteLn (GetACP);
  WriteLn (GetConsoleCP);
end.

Tomas


More information about the fpc-devel mailing list