Reputation: 65
Does anyone know if there is any possibility about how can I for example transcribe Russian input to latin?
There is any framework that supports that? I was searching Charset but it doesn't support this case
Thx in Advance.
Upvotes: 0
Views: 1151
Reputation: 14348
Map<Character, String> translit = new HashMap<>();
static {
translit.put('а', "a");
translit.put('б', "b");
translit.put('в', "v");
// ...
translit.put('ж', "zh");
// and so on
}
public String transliterate(String input) {
char[] c = input.toCharArray();
StringBuilder output = new StringBuilder();
for (char ch : c) {
output.append(translit.contains(ch) ? translit.get(ch) : String.valueOf(ch));
}
return output.toString();
}
Upvotes: 1