Thread overview | ||||||||
---|---|---|---|---|---|---|---|---|
|
October 17, 2017 readln of german Umlaute (terminal.d) / readln) | ||||
---|---|---|---|---|
| ||||
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é |
October 17, 2017 Re: readln of german Umlaute (terminal.d) / readln) | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andre Pany | 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..
|
October 17, 2017 Re: readln of german Umlaute (terminal.d) / readln) | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andre Pany | Or try this newest commit https://github.com/adamdruppe/arsd/blob/master/terminal.d and see if it works better for you. |
October 17, 2017 Re: readln of german Umlaute (terminal.d) / readln) | ||||
---|---|---|---|---|
| ||||
Posted in reply to Adam D. Ruppe | 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; } |
October 17, 2017 Re: readln of german Umlaute (terminal.d) / readln) | ||||
---|---|---|---|---|
| ||||
Posted in reply to Adam D. Ruppe | 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.
|
October 17, 2017 Re: readln of german Umlaute (terminal.d) / readln) | ||||
---|---|---|---|---|
| ||||
Posted in reply to Adam D. Ruppe | 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é
|
Copyright © 1999-2021 by the D Language Foundation