Since our system has now switched to UTF-8 I have to replace all existing Unicode_escapes with the corresponding UTF-8 chars. Unfortunately my code does not work and I don't know why
I feed the method with a string e.g.
ui.activityFeed.currentActivities=Aktuelle Aktivit\u00e4ten
and expect this as the return that comes back:
ui.activityFeed.currentActivities=Aktuelle Aktivitäten
private static String replaceUmlaute(String line) {
System.out.println(line);
final ByteBuffer buffer = StandardCharsets.UTF_8.encode(line);
final String utf8EncodedString = StandardCharsets.UTF_8.decode(buffer).toString();
System.out.println(utf8EncodedString);
return utf8EncodedString;
}
Result:
ui.activityFeed.currentActivities=Aktuelle Aktivit\u00e4ten
ui.activityFeed.currentActivities=Aktuelle Aktivit\u00e4ten
I already tried the replace method but that didn't work either Thanks for your help