In my app I need to generate passwords based on all available national characters, like:
private String generatePassword(String charSet, int passwordLength) {
char[] symbols=charSet.toCharArray();
StringBuilder sbPassword=new StringBuilder();
Random wheel = new Random();
for (int i = 0; i < passwordLength; i++) {
int random = wheel.nextInt(symbols.length);
sbPassword.append(symbols[random]);
}
return sbPassword.toString();
}
For Latin we have smth like:
charSet="AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz";
How to get similar String
containing all national characters (alphabet) let's say for Thai, Arab or Hebrew?
I mean, all we know that Unicode contains all national characters available for any Locale, so there has to be a way to get them, otherwise I'd be forced to hardcode national alphabets - which is ugly... (in my case my app supports more than 10 locales)