PDA

View Full Version : list of available characters from keyboard



alainstgt
20th November 2014, 16:17
I have written a program calculating a quality index for a password. For this, I need to know how many characters are available in each group of characters (lowercase letter, uppercase letter, arabic numerals, others (punctuation, symbols, spaces)).

How can I achieve this?

QLocale::language() and QLocale::country() are giving the ground information.
Now, if I do not want to precompute for each language the number of characters belonging to each group as defined above, I should be able to "scan" the keyboard.
To do that, I would need to know how the physical keys are mapped into software event through the keyboard driver. Is that information available? and if yes, how to access it?

May be somebody has another idea how to achieve the task!

Thank you for your valuable time
Alain

ChrisW67
20th November 2014, 22:44
There is little correlation between the keys on the keyboard and the characters than can be composed using the keyboard. My US English keyboard is quite capable of generating all manner of non-English characters just by telling the OS it to treat it differently.

If you want to check that the characters in a given password meet certain strength criteria then just check each character in turn using QChar::isLetter(), isDigit(), isPunct() etc. Every Unicode code point is already characterised for you. If you really want to know how many code points in the Unicode basic Multilingual plane fall into each category then you could simply interate all 65000 or so code points.

alainstgt
20th November 2014, 23:48
Hello Chris,

I check each character of the password as you stipulate and build up the sum in each character group.
But I need also to know how many characters are available in each group at all to build up weights. For example it makes no sense to ask for uppercase letters in language which have no of them.

I am aware that you can reach every character defined in unicode by entering the unicode code of the character , but users seldom do that and restrict their use to those characters available with their keyboard. That's why I am not interested in knowing how many letters digits, punctuation signs and so on are available in unicode but restricted to those accessible directly through the keyboard.