hxcs icon indicating copy to clipboard operation
hxcs copied to clipboard

Windows console unicode input

Open dluciv opened this issue 10 years ago • 0 comments

When running on Windows, generated C# code breaks non-ASCII input on Windows console.

var s : String = stdin.readLine();
trace("You typed: " + s);

is translated to:

global::haxe.io.Input stdin = global::Sys.stdin();
string s4 = stdin.readLine();

I have not debugged it deeply and have not discovered what and where exactly it goes wrong, but when I type some non-ASCII, e.g. привет, it spoils my input.

Sys.stdout().writeString(...) also breaks encoding.

As far as I briefly looked into the code, when writing a string, it encodes it as UTF-8 (which itself is very good, but not compatible with Windows =)). When reading a string, it barely creates characters from stdin bytes (which is neither compatible with Windows nor good =)).

Both trace and Sys.println work well (as expcted, because they do not attempt to perform low-level conversions theirselves).

Nearly same problem is for Java target.

This can be overall design issue of Haxe, in this case sorry for disturbing (and will be glad to know how to work it around =)).

dluciv avatar Nov 23 '14 09:11 dluciv