HaxeFoundation / HaxeFoundation/hxcs

Windows console unicode input

Open
#15 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Haxe
Stars
56
Forks
21
PR merge metrics
No merged PRs in 30d

Description

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 =)).

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by tracing the Windows console paths for Sys.stdin().readLine(), Sys.stdout().writeString(...), trace, and Sys.println in the generated C# support code. Compare their handling of non-ASCII input and output, then verify that the reported example preserves text on Windows; the issue also notes a similar problem for the Java target.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, java
Domain
cli, operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.