decks: improved deck import to support unicode card names from LTR, UGL and other sets, added verify tests for name converters (closes #10465)

This commit is contained in:
Oleg Agafonov 2023-06-14 03:16:24 +04:00
parent eebb82c591
commit d91147f01a
3 changed files with 78 additions and 16 deletions

View file

@ -6,22 +6,34 @@ public class CardNameUtil {
public static final Pattern CARD_NAME_PATTERN = Pattern.compile("[ !\"&',\\-./0-9:A-Za-z]+");
/**
* Convert card names with unicode symbols to ascii, uses to deck import from a third party services
*
* @param name
* @return
*/
public static String normalizeCardName(String name) {
// new symbols checks in verify test, no need to manually search it
return name
.replace("&", "//")
.replace("///", "//")
.replace("Æ", "Ae")
.replace("ö", "A")
.replace("ö", "o")
.replace("û", "u")
.replace("í", "i")
.replace("â", "a")
.replace("á", "a")
.replace("à", "a")
.replace("é", "e")
.replace("ú", "u")
.replace("", "+")
.replace("", "*");
.replace("&", "//")
.replace("///", "//")
.replace("Æ", "Ae")
.replace("ö", "A")
.replace("ö", "o")
.replace("û", "u")
.replace("í", "i")
.replace("â", "a")
.replace("á", "a")
.replace("à", "a")
.replace("é", "e")
.replace("ú", "u")
.replace("", "+")
.replace("", "*")
.replace("ó", "o")
.replace("ä", "a")
.replace("ü", "u")
.replace("É", "E")
.replace("ñ", "n")
.replace("®", "");
}
}