Search on server with ISO8859

This commit is contained in:
M66B 2021-06-04 11:32:55 +02:00
parent 0f5a6d75c2
commit fd190fdee1
1 changed files with 10 additions and 2 deletions

View File

@ -42,6 +42,7 @@ import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.Serializable; import java.io.Serializable;
import java.lang.reflect.Constructor; import java.lang.reflect.Constructor;
import java.nio.charset.CharsetEncoder;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.text.Normalizer; import java.text.Normalizer;
import java.util.ArrayList; import java.util.ArrayList;
@ -732,8 +733,15 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
.replace("ß", "ss") // Eszett .replace("ß", "ss") // Eszett
.replace("ij", "ij"); .replace("ij", "ij");
search = Normalizer search = Normalizer
.normalize(search, Normalizer.Form.NFKD) .normalize(search, Normalizer.Form.NFKD);
.replaceAll("[^\\p{ASCII}]", "");
CharsetEncoder encoder = StandardCharsets.ISO_8859_1.newEncoder();
StringBuilder sb = new StringBuilder();
for (int i = 0; i < search.length(); i++) {
char c = search.charAt(i);
sb.append(encoder.canEncode(c) ? c : '?');
}
search = sb.toString();
} }
List<String> word = new ArrayList<>(); List<String> word = new ArrayList<>();