Burkhard
02/20/2020, 9:05 AM\u1f1e9\u1f1ea
but for some reason only the first 4 chars of each unicode codepoint are recognized as part of the character. Do I have to encode unicode codepoints as a surrogate pair if they aren’t part of the BMP or is there a better way to do this?spand
02/20/2020, 9:09 AMBurkhard
02/20/2020, 9:14 AM\u1f1e
followed by a 9
Burkhard
02/20/2020, 9:14 AMspand
02/20/2020, 9:23 AMprivate val wantedRegex: Regex by lazy { "^[a-zA-Z]{2}$".toRegex() }
private fun isoToUnicodeFlag(iso: String) : String? {
return if (wantedRegex.matches(iso)) {
val first = charToFunkyIsoChar(iso[0].toLowerCase())
val second = charToFunkyIsoChar(iso[1].toLowerCase())
"\uD83C$first\uD83C$second"
} else null
}
//<https://en.wikipedia.org/wiki/Regional_Indicator_Symbol#Unicode_Block>
private fun charToFunkyIsoChar(char: Char) : Char {
return ((char.toInt() - 'a'.toInt()) + '\uDDE6'.toInt()).toChar()
}
spand
02/20/2020, 9:26 AMBurkhard
02/20/2020, 9:27 AMBurkhard
02/20/2020, 9:29 AMspand
02/20/2020, 9:29 AMspand
02/20/2020, 9:30 AMBurkhard
02/20/2020, 9:31 AM"👨👩👦👦"
? I think the answer is 6 or 7.spand
02/20/2020, 9:34 AM