I am working on a service which will replace Unicode characters by characters of a reduced unicode charset. For example characters like öäü
are replaced by oau
But Unicode characers with more than 2 Bytes make trouble, for example the letter L̥̄
It consists of three bytes.
That is my code to replace the characters:
for (int i = 0; i < sourceString.length(); i++) {
String searchChar =sourceString.substring(i, i + 1);
String replaceChar = charMap.get(searchChar);
System.out.println ("Char: " + searchChar + " is getting replaced by " + replaceChar);
targetString += replaceChar;
}
That will output:
Char: L is getting replaced by L
Char: ̥ is getting replaced by null
Char: ̄ is getting replaced by null
Target: Lnullnull
Instead of substring I tried codePointAt, but the result was the same.
How can I handle that?