1

I want to show country flag using it's name like "IR" , "US" ,"CN", ...
I used below code but it does not work in android 5.1.1 and below and it's just shows "IR" instead of flag. my code output so any body can help me?

fun getCountryEmoji(country: String): String {
    val flagOffset = 0x1F1E6
    val asciiOffset = 0x41
    val firstChar = Character.codePointAt(country, 0) - asciiOffset + flagOffset
    val secondChar = Character.codePointAt(country, 1) - asciiOffset + flagOffset
    val flag = String(Character.toChars(firstChar)) + String(Character.toChars(secondChar))
    return flag
}

0 Answers0