readln of german Umlaute (terminal.d) / readln)

notna notna.remove.this at ist-einmalig.de
Tue Oct 17 16:01:51 UTC 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;
}


More information about the Digitalmars-d-learn mailing list