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

Ondrej Pokorny lazarus at kluug.net
Wed Aug 30 17:12:34 CEST 2023


On 30.08.2023 17:04, Tomas Hajny via fpc-devel wrote:
> On 2023-08-30 16:32, Ondrej Pokorny via fpc-devel wrote:
>> If you mean
>> https://stackoverflow.com/questions/56419639/what-does-beta-use-unicode-utf-8-for-worldwide-language-support-actually-do, 
>>
>> then no, I don't have this option checked. However, even if I had it
>> checked (I don't), it couldn't make a difference, because I didn't
>> rely on the output displayed on console, but I actually checked the
>> codepage of the compiler output by redirecting it to a file and
>> checking the content of that file as well.
>>
>> So did I:
>>
>> See output.txt in the attachment. It is the output from redirection
>> with "> output.txt". The output is double-encoded on my system (UTF-8
>> as CP-850) - it means I have to convert it first from CP-850 to ANSI,
>> then I see correct raw UTF-8 byte stream.
>
> Interesting, but it doesn't change anything on the fact that my result 
> is different (and correct) and I don't think that my configuration is 
> special in any way...

Yes, it is strange. Mattias and Zeljko have the same output like me 
(Zeljko wrote about it in the Lazarusdev mailing list). So, currently 
you are the only one with different result from a group of 4 people 
involved in the same test :)


> Could you please change my test program sent earlier by changing 
> "WriteLn (GetConsoleCP);" to "WriteLn (GetConsoleOutputCP);" recompile 
> and check output of that one (GetConsoleCP is not useful in this 
> context, that was my fault :-( ) - just in case?

GetConsoleOutputCP = GetConsoleCP = 850 on my system.


> Do you get a different behaviour if using a stock 3.2.2 compiler (the 
> one distributed by the FPC team, not a Lazarus distribution)?

Stock FPC 3.2.2 has the same output:

Free Pascal Compiler version 3.2.2 [2021/05/15] for i386
Copyright (c) 1993-2021 by Florian Klaempfl and others
Target OS: Win32 for i386
Compiling TestNote.lpr
TestNote.lpr(11,3) Note: User defined: ä
Linking TestNote.exe
13 lines compiled, 0.1 sec, 28864 bytes code, 1332 bytes data
1 note(s) issued

Ondrej



More information about the fpc-devel mailing list