Update German uppercase sharp S

This commit is contained in:
Aleksandras Kostarevas 2024-07-23 19:41:06 +03:00
parent b3d12fc7a1
commit bb00bdbcab

View File

@ -20,6 +20,7 @@ import org.futo.inputmethod.annotations.UsedForTesting;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Locale;
import javax.annotation.Nonnull;
@ -41,6 +42,12 @@ public final class StringUtils {
private static final char CHAR_LINE_SEPARATOR = 0X2028;
private static final char CHAR_PARAGRAPH_SEPARATOR = 0X2029;
// Java's .toUpperCase converts Sharp S to "SS", this is a workaround
private static final HashMap<Integer, Integer> uppercaseCodeReplacements = new HashMap<>();
static {
uppercaseCodeReplacements.put(0x00DF, 0x1E9E); // ß :
}
private StringUtils() {
// This utility class is not publicly instantiable.
}
@ -607,6 +614,15 @@ public final class StringUtils {
if (label == null) {
return label;
}
if(codePointCount(label) == 1) {
int code = label.codePointAt(0);
Integer replacementCode = uppercaseCodeReplacements.get(code);
if(replacementCode != null) {
return new String(Character.toChars(replacementCode));
}
}
return label.toUpperCase(getLocaleUsedForToTitleCase(locale));
}