Reputation: 31
Why this "Á" alphabet doesn't change? this code works on the other alphabet but Á.
public class Convert {
static String turkishCharacterConverter(String s) {
StringBuilder x = new StringBuilder();
char[] charArr = s.toLowerCase().toCharArray();
for (int i = 0; i < charArr.length; i++) {
if (charArr[i] == '˝') {
x.append('I');
} else if (charArr[i] == '˛') {
x.append("S");
} else if (charArr[i] == '') {
x.append("G");
} else if (charArr[i] == 'ˆ') {
x.append("O");
} else if (charArr[i] == '¸') {
x.append("U");
} else if (charArr[i] == 'Á') {
x.append("C");
} else {
x.append(s.charAt(i));
}
}
return x.toString();
}
public static void main(String[] args) {
System.out.println(turkishCharacterConverter("˝˛˝˝nda"));
System.out.println(turkishCharacterConverter("ˆlÁt¸¸m"));
}
}
and java print
ISIGInda
OlÁtUGUm ( i want to make java print "OlCtUGUm" )
Upvotes: 0
Views: 393
Reputation: 1315
It is making Á as á
because of using lowercase. try using this
if(charArr[i] == 'á')
Upvotes: 2
Reputation: 328568
Because of char[] charArr = s.toLowerCase().toCharArray();
You are comparing Á
with its lower case á
. The other characters are already in lower case so it works fine for them.
Upvotes: 8