Skip to content
This repository was archived by the owner on Nov 9, 2021. It is now read-only.
This repository was archived by the owner on Nov 9, 2021. It is now read-only.

UTF8ToConsole bug #10

Open
Open
@JPGygax68

Description

@JPGygax68

There is a problem with UTF8ToConsole on my Windows 10.

I live in Switzerland, but Windows is set to English, and chcp displays 437 as my active codepage.

The following program:

uses LazUTF8, Crt;

var
  S: String;
begin
  Writeln('Writing the name from a string literal: "Jérémie"');
    // ^ garbage 

  Writeln('Converting UTF-8 string to console (should be implicit?): "', UTF8ToConsole(S), '"');
    // ^ garbage

  Writeln('Converting UTF-8 string to Windows CodePage: "', UTF8ToWinCP(S), '"');
    // ^ TODO: works, but how to make it portable?

  ReadKey;
end.

produces the following output:

Writing the name from a string literal: "Jérémie"
Converting UTF-8 string to console (should be implicit?): "Jérémie"
Converting UTF-8 string to Windows CodePage: "Jérémie"

The strange thing is that UTF8ToConsole immediately calls UTF8ToWinCP, which (as demonstrated by the last test case, and also verified using the debugger) produces the right result. The remaining code of UTF8ToConsole however then further processes that result, so that the end result is wrong.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions