我有一个小方法。它获取带有 eng 字符的字符串并返回 rus 字符串(音译);但它有问题。我不知道是什么。它返回的不是俄语字符串,而是一些像 "[C@4057db80"; 这样的垃圾。
public String getRussianSting(String engString) {
char[] engCharString = engString.toLowerCase().toCharArray();
char[] rusCharString = new char[30];
for (int i = 0; i <= engCharString.length - 1; i++) {
if (engCharString[i] == ' ')
continue;
if (i + 1 <= engCharString.length - 1) {
if (engCharString[i] == 'c' && engCharString[i + 1] == 'h') {
rusCharString[i] = 'ч';
i++;
continue;
} else if (engCharString[i] == 's' && engCharString[i + 1] == 'h') {
rusCharString[i] = 'ш';
i++;
continue;
} else if (engCharString[i] == 't' && engCharString[i + 1] == 'z') {
rusCharString[i] = 'ц';
i++;
continue;
} else if (engCharString[i] == 'y' && engCharString[i + 1] == 'i') {
rusCharString[i] = 'ы';
i++;
} else if (engCharString[i] == 'y' && engCharString[i + 1] == 'e') {
rusCharString[i] = 'э';
i++;
continue;
} else if (engCharString[i] == 'y' && engCharString[i + 1] == 'u') {
rusCharString[i] = 'ю';
i++;
continue;
} else if (engCharString[i] == 'y' && engCharString[i + 1] == 'a') {
rusCharString[i] = 'я';
i++;
continue;
}
}
switch (engCharString[i]) {
case 'a':
rusCharString[i] = 'а';
break;
case 'b':
rusCharString[i] = 'б';
break;
case 'v':
rusCharString[i] = 'в';
break;
case 'g':
rusCharString[i] = 'г';
break;
case 'd':
rusCharString[i] = 'д';
break;
case 'e':
rusCharString[i] = 'е';
break;
case 'j':
rusCharString[i] = 'ж';
break;
case 'z':
rusCharString[i] = 'з';
break;
case 'i':
rusCharString[i] = 'и';
break;
case 'k':
rusCharString[i] = 'к';
break;
case 'l':
rusCharString[i] = 'л';
break;
case 'm':
rusCharString[i] = 'м';
break;
case 'n':
rusCharString[i] = 'н';
break;
case 'o':
rusCharString[i] = 'о';
break;
case 'p':
rusCharString[i] = 'п';
break;
case 'r':
rusCharString[i] = 'р';
break;
case 's':
rusCharString[i] = 'с';
break;
case 't':
rusCharString[i] = 'т';
break;
case 'u':
rusCharString[i] = 'у';
break;
case 'f':
rusCharString[i] = 'ф';
break;
case 'h':
rusCharString[i] = 'х';
break;
case '\'':
rusCharString[i] = 'ь';
break;
default:
break;
}
}
return rusCharString.toString();
}