Since you do not seem to be compatible with the situation, you can first type in uppercase or lowercase strings, but you would like to know the locale:
final String xu = x.toUpperCase(Locale.US);
for (int i = 0; i < xu.length(); ++i) {
arr[i] = xu.charAt(i) - 'A' + 1;
}
An alternative loop would use:
// Casing not necessary.
for (int i = 0; i < x.length(); ++i) {
// One character
String letter = x.substr(i, i+1);
// A is 10 in base 11 and higher. Z is 35 in base 36.
// Subtract 9 to have A-Z be 1-26.
arr[i] = Integer.valueOf(letter, 36) - 9;
}
source
share