[fpc-devel] Console encoding on Windows, output to file with ">"
Petr Kristan
petr.kristan at epos.cz
Wed May 3 09:07:51 CEST 2017
On Wed, May 03, 2017 at 08:34:14AM +0200, Ondrej Pokorny wrote:
> Hello,
>
> I have a simple FPC program:
>
> ---
> program GermanTest;
>
> {$codepage utf8}
> begin
> Writeln('ÄäÖöÜüß');
> end.
> ---
>
> If I run it in the console, I see correct characters:
>
> BUT when I redirect the output to a file with ">" :
>
> GermanTest.exe > GermanTest.txt I get corrupted characters "Ž„™”š?á" (see
> attachment).
>
> I tried various possibilities but either the console output is correct or
> the file output is correct. Never both of them.
>
> E.g.
> ---
> program GermanTest;
>
> {$codepage utf8}
>
> uses
> Windows, SysUtils, Classes;
>
> begin
> SetConsoleOutputCP(CP_UTF8);
>
> Writeln('ÄäÖöÜüß');
Try:
Writeln(UTF8ToSys('ÄäÖöÜüß'));
> end.
> ---
>
> Works fine for file output but the console shows wrong characters.
>
> What should I do so that both outputs are correct? Or is it an FPC bug?
> Delphi works fine - both outputs are correct.
>
> FPC version: current trunk 3.1.1 Windows, 32bit.
> OS: Windows 10, 64bit
>
> Ondrej
>
> УУЄУУЖУУМУ
> _______________________________________________
> fpc-devel maillist - fpc-devel at lists.freepascal.org
> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
--
Petr Kristan
.
EPOS PRO s.r.o., Smilova 333, 530 02 Pardubice
tel: +420 461101401 Czech Republic (Eastern Europe)
fax: +420 461101481
More information about the fpc-devel
mailing list