Let's talk like a Roman

This commit is contained in:
M66B
2021-10-14 19:53:53 +02:00
parent 65403e2df1
commit a9585547e9
5 changed files with 31 additions and 8 deletions

View File

@@ -174,6 +174,11 @@ public class Helper {
// https://developer.android.com/distribute/marketing-tools/linking-to-google-play#PerformingSearch
private static final String PLAY_STORE_SEARCH = "https://play.google.com/store/search";
private static final String[] ROMAN_1000 = {"", "M", "MM", "MMM"};
private static final String[] ROMAN_100 = {"", "C", "CC", "CCC", "CD", "D", "DC", "DCC", "DCCC", "CM"};
private static final String[] ROMAN_10 = {"", "X", "XX", "XXX", "XL", "L", "LX", "LXX", "LXXX", "XC"};
private static final String[] ROMAN_1 = {"", "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX"};
static final Pattern EMAIL_ADDRESS
= Pattern.compile(
"[\\S]{1,256}" +
@@ -1526,6 +1531,15 @@ public class Helper {
}
}
public static String toRoman(int value) {
if (value < 0 || value >= 4000)
return Integer.toString(value);
return ROMAN_1000[value / 1000] +
ROMAN_100[(value % 1000) / 100] +
ROMAN_10[(value % 100) / 10] +
ROMAN_1[value % 10];
}
// Files
static String sanitizeFilename(String name) {