[fpc-devel] Console encoding on Windows, output to file with ">"

Ondrej Pokorny lazarus at kluug.net
Wed May 3 11:43:59 CEST 2017


On 03.05.2017 9:07, Petr Kristan wrote:
> Try:
>      Writeln(UTF8ToSys('ÄäÖöÜüß'));

No, it doesn't help.

I debugged into the issue and found out that the exported file was in 
DOS-850 encoding (the same as the console lived in). Delphi changes the 
output encoding to "DefaultSystemCodePage" if Output is different from 
console. This code shows the same behavior as in Delphi:

---
program GermanTest;

{$codepage utf8}

uses
   Windows, SysUtils;

begin
   if GetFileType(TTextRec(Output).Handle) <> FILE_TYPE_CHAR then
     SetTextCodePage(Output, DefaultSystemCodePage);
   Writeln('ÄäÖöÜüß');
end.
---

I reported it in bug tracker: https://bugs.freepascal.org/view.php?id=31746

On 03.05.2017 8:56, Michael Thompson wrote:
> When I open the attachment on my PC, I see the correct characters

Upps. My fault - I sent the wrong (= with correct characters :D) file.

Ondrej



More information about the fpc-devel mailing list