digitalmars.D.learn - readln of german Umlaute (terminal.d) / readln)
- Andre Pany (17/17) Oct 17 2017 Hi,
- Adam D. Ruppe (4/6) Oct 17 2017 Do you have a little test program I can copy/paste?
- Adam D. Ruppe (3/3) Oct 17 2017 Or try this newest commit
- notna (31/34) Oct 17 2017 - Here is what I use in one of my tools... and I never had
- user1234 (2/5) Oct 17 2017 in the commit message: ~~ascii~~ ANSI.
- Andre Pany (6/9) Oct 17 2017 Thank you Adam. The ascii thing was causing the issue in the
Hi, I want to read passwords from the console (should be work on windows / linux / macos). Adam Ruppe has a quite nice library (terminal.d) which allows to deactivating the echo to the console, which makes sense for passwords. But I do not get it working with terminal.d nor with std.stdio: readln if it comes to special characters like ö. The password is saved to a file. readln will save for "ööö": "x94x94x94\n" terminal.d will save: CCHCCHCCH Changing the code page (CHCP 65001) will lead to the effect that empty strings are saved for both (readln, terminal.d) Does someone already solved this problem and has a solution working on all operation systems? Kind regadrs André
Oct 17 2017
On Tuesday, 17 October 2017 at 12:08:57 UTC, Andre Pany wrote:I want to read passwords from the console (should be work on windows / linux / macos).Do you have a little test program I can copy/paste? I suspect this is because I called ReadConsoleInputA instead of W for some weird reson..
Oct 17 2017
Or try this newest commit https://github.com/adamdruppe/arsd/blob/master/terminal.d and see if it works better for you.
Oct 17 2017
On Tuesday, 17 October 2017 at 15:02:29 UTC, Adam D. Ruppe wrote:Or try this newest commit https://github.com/adamdruppe/arsd/blob/master/terminal.d and see if it works better for you.- Here is what I use in one of my tools... and I never had problems with German password so far ;) string getPassword(char mask = '*') { import std.stdio; import libs.terminal; auto term = Terminal(ConsoleOutputType.linear); auto input = RealTimeConsoleInput(&term, ConsoleInputFlags.raw); string pass; dchar ch; ch = input.getch(); while(ch != '\r' && ch != '\n') { import std.range; if(ch == '\b' && !pass.empty) { pass = pass[0..$-1]; write('\b'); stdout.flush; } else { pass ~= ch; write(mask); stdout.flush(); } ch = input.getch(); } return pass; }
Oct 17 2017
On Tuesday, 17 October 2017 at 15:02:29 UTC, Adam D. Ruppe wrote:Or try this newest commit https://github.com/adamdruppe/arsd/blob/master/terminal.d and see if it works better for you.in the commit message: ~~ascii~~ ANSI.
Oct 17 2017
On Tuesday, 17 October 2017 at 15:02:29 UTC, Adam D. Ruppe wrote:Or try this newest commit https://github.com/adamdruppe/arsd/blob/master/terminal.d and see if it works better for you.Thank you Adam. The ascii thing was causing the issue in the windows console. Now it is working fine. Kind regards André
Oct 17 2017