flag๏ƒ

Flag emoji for Python.

Converts flag emoji to ASCII and other way round.

Source on Github

This is based on http://schinckel.net/2015/10/29/unicode-flags-in-python/ by schinckel

Example๏ƒ

>>> import flag

>>> flag.flag("IL")
'๐Ÿ‡ฎ๐Ÿ‡ฑ'

>>> flag.flag("GBENG")
'๐Ÿด๓ ง๓ ข๓ ฅ๓ ฎ๓ ง๓ ฟ'

>>> flag.flagize("Flag of Israel :IL:")
'Flag of Israel ๐Ÿ‡ฎ๐Ÿ‡ฑ'

>>> flag.dflagize("Flag of Israel ๐Ÿ‡ฎ๐Ÿ‡ฑ")
'Flag of Israel :IL:'

>>> flag.flagize("England :gb-eng: is part of the UK :GB:", subregions=True)
'England ๐Ÿด๓ ง๓ ข๓ ฅ๓ ฎ๓ ง๓ ฟ is part of the UK ๐Ÿ‡ฌ๐Ÿ‡ง'

>>> flag.dflagize("England ๐Ÿด๓ ง๓ ข๓ ฅ๓ ฎ๓ ง๓ ฟ is part of the UK ๐Ÿ‡ฌ๐Ÿ‡ง", subregions=True)
'England :gb-eng: is part of the UK :GB:'

Install๏ƒ

pip install emoji-country-flag

See: https://pypi.org/project/emoji-country-flag/

Hint

If you donโ€™t see the flags in your browser, try with your phone

QR Code containg https://flag.readthedocs.org https://flag.readthedocs.org

How it works๏ƒ

All the flag emoji are actually composed of two unicode letters. These are the 26 regional indicator symbols.

Alone they look like this: ๐Ÿ‡ฆ ๐Ÿ‡ง ๐Ÿ‡จ ๐Ÿ‡ฉ ๐Ÿ‡ช ๐Ÿ‡ซ ๐Ÿ‡ฌ ๐Ÿ‡ญ ๐Ÿ‡ฎ ๐Ÿ‡ฏ ๐Ÿ‡ฐ ๐Ÿ‡ฑ ๐Ÿ‡ฒ ๐Ÿ‡ณ ๐Ÿ‡ด ๐Ÿ‡ต ๐Ÿ‡ถ ๐Ÿ‡ท ๐Ÿ‡ธ ๐Ÿ‡น ๐Ÿ‡บ ๐Ÿ‡ป ๐Ÿ‡ผ ๐Ÿ‡ฝ ๐Ÿ‡พ ๐Ÿ‡ฟ

If you pair them up according to ISO 3166 some browsers and phones will display a flag. For example TW is Taiwan: ๐Ÿ‡น + ๐Ÿ‡ผ = ๐Ÿ‡น๐Ÿ‡ผ

So, to encode an ASCII code like :TW: to ๐Ÿ‡น๐Ÿ‡ผ, we just need to convert the ASCII T and R to the corresponding regional indicator symbols ๐Ÿ‡น and ๐Ÿ‡ผ. To reverse it, we translate the regional indicator symbols back to ASCII letters.

How do subregional flags work?

Functions๏ƒ

flag.flag(countrycode: str) str[source]๏ƒ

Encodes a single flag to unicode. Two letters are converted to regional indicator symbols Three or more letters/digits are converted to tag sequences. Dashes, colons and other symbols are removed from input, only a-z, A-Z and 0-9 are processed.

In general a valid flag is either a two letter code from ISO 3166 (e.g. GB), a code from ISO 3166-2 (e.g. GBENG) or a numeric code from ISO 3166-1. However, not all codes produce valid unicode, see http://unicode.org/reports/tr51/#flag-emoji-tag-sequences for more information. From ISO 3166-2 only England gbeng, Scotland gbsct and Wales gbwls are considered RGI (recommended for general interchange) by the Unicode Consortium, see http://www.unicode.org/Public/emoji/latest/emoji-test.txt

Parameters:

countrycode (str) โ€“ Two letter ISO 3166 code or a regional code from ISO 3166-2.

Returns:

The unicode representation of the flag

Return type:

str

flag.flagize(text: str, subregions: bool = False) str[source]๏ƒ

Encode flags. Replace all two letter codes :XX: with unicode flags (emoji flag sequences)

Parameters:
  • text (str) โ€“ The text

  • subregions (bool) โ€“ Also replace subregional/subdivision codes :xx-xxx: with unicode flags (flag emoji tag sequences).

Returns:

The text with all occurrences of :XX: replaced by unicode flags

Return type:

str

flag.dflagize(text: str, subregions: bool = False) str[source]๏ƒ

Decode flags. Replace all unicode country flags (emoji flag sequences) in text with ascii two letter code :XX:

Parameters:
  • text (str) โ€“ The text

  • subregions (bool) โ€“ Also replace subregional/subdivision flags (flag emoji tag sequences) with :xx-xxx:

Returns:

The text with all unicode flags replaced by ascii sequence :XX:

Return type:

str

flag.flagize_subregional(text: str) str[source]๏ƒ

Encode subregional/subdivision flags. Replace all regional codes :xx-xxx: with unicode flags (flag emoji tag sequences)

Parameters:

text (str) โ€“ The text

Returns:

The text with all occurrences of :xx-xxx: replaced by unicode flags

Return type:

str

flag.dflagize_subregional(text: str) str[source]๏ƒ

Decode subregional/subdivision flags. Replace all unicode regional flags (flag emoji tag sequences) in text with their ascii code :xx-xxx:

Parameters:

text (str) โ€“ The text

Returns:

The text with all regional flags replaced by ascii sequence :xx-xxx:

Return type:

str

class flag.Flag(prefix_str: str = ':', suffix_str: str = ':', warn: bool = True)[source]๏ƒ

Use this class if you want a different prefix and suffix instead of colons. Offers the same methods as the module.

__init__(prefix_str: str = ':', suffix_str: str = ':', warn: bool = True) None[source]๏ƒ

Set a custom prefix and suffix. Instead of :XY: it will use {prefix}XY{suffix}.

To encode subregional flags, use a suffix that is either longer than 4 characters or that does not contain A-Z, a-z, 0-9 and does not start with a - (minus).

Parameters:
  • prefix_str (str) โ€“ The leading symbols

  • suffix_str (str) โ€“ The trailing symbols

dflagize(text: str, subregions: bool = False) str[source]๏ƒ

Decode flags. Replace all unicode country flags (emoji flag sequences) in text with ascii two letter code {prefix}XX{suffix}

Parameters:
  • text (str) โ€“ The text

  • subregions (bool) โ€“ Also replace subregional/subdivision flags (flag emoji tag sequences) with {prefix}xx-xxx{suffix}

Returns:

The text with all unicode flags replaced by ascii sequence {prefix}XX{suffix}

Return type:

str

dflagize_subregional(text: str) str[source]๏ƒ

Decode subregional/subdivision flags. Replace all unicode regional flags (flag emoji tag sequences) in text with their ascii code {prefix}xx-xxx{suffix}

Parameters:

text (str) โ€“ The text

Returns:

The text with all regional flags replaced by ascii sequence {prefix}xx-xxx{suffix}

Return type:

str

flagize(text: str, subregions: bool = False) str[source]๏ƒ

Encode flags. Replace all two letter codes {prefix}XX{suffix} with unicode flags (emoji flag sequences)

For this method the suffix should not contain A-Z, a-z or 0-9 and not start with a - (minus).

Parameters:
  • text (str) โ€“ The text

  • subregions (bool) โ€“ Also replace subregional/subdivision codes {prefix}xx-xxx{suffix} with unicode flags (flag emoji tag sequences).

Returns:

The text with all occurrences of {prefix}XX{suffix} replaced by unicode flags

Return type:

str

flagize_subregional(text: str) str[source]๏ƒ

Encode subregional/subdivision flags. Replace all regional codes {prefix}xx-xxx{suffix} with unicode flags (flag emoji tag sequences)

For this method the suffix should not contain A-Z, a-z or 0-9 and not start with a - (minus).

Parameters:

text (str) โ€“ The text

Returns:

The text with all occurrences of {prefix}xx-xxx{suffix} replaced by unicode flags

Return type:

str

Supported emojis and patterns๏ƒ

(List may be incomplete)

Code

Emoji

:UN:

๐Ÿ‡บ๐Ÿ‡ณ

:AC:

๐Ÿ‡ฆ๐Ÿ‡จ

:AD:

๐Ÿ‡ฆ๐Ÿ‡ฉ

:AE:

๐Ÿ‡ฆ๐Ÿ‡ช

:AF:

๐Ÿ‡ฆ๐Ÿ‡ซ

:AG:

๐Ÿ‡ฆ๐Ÿ‡ฌ

:AI:

๐Ÿ‡ฆ๐Ÿ‡ฎ

:AL:

๐Ÿ‡ฆ๐Ÿ‡ฑ

:AM:

๐Ÿ‡ฆ๐Ÿ‡ฒ

:AO:

๐Ÿ‡ฆ๐Ÿ‡ด

:AQ:

๐Ÿ‡ฆ๐Ÿ‡ถ

:AR:

๐Ÿ‡ฆ๐Ÿ‡ท

:AS:

๐Ÿ‡ฆ๐Ÿ‡ธ

:AT:

๐Ÿ‡ฆ๐Ÿ‡น

:AU:

๐Ÿ‡ฆ๐Ÿ‡บ

:AW:

๐Ÿ‡ฆ๐Ÿ‡ผ

:AX:

๐Ÿ‡ฆ๐Ÿ‡ฝ

:AZ:

๐Ÿ‡ฆ๐Ÿ‡ฟ

:BA:

๐Ÿ‡ง๐Ÿ‡ฆ

:BB:

๐Ÿ‡ง๐Ÿ‡ง

:BD:

๐Ÿ‡ง๐Ÿ‡ฉ

:BE:

๐Ÿ‡ง๐Ÿ‡ช

:BF:

๐Ÿ‡ง๐Ÿ‡ซ

:BG:

๐Ÿ‡ง๐Ÿ‡ฌ

:BH:

๐Ÿ‡ง๐Ÿ‡ญ

:BI:

๐Ÿ‡ง๐Ÿ‡ฎ

:BJ:

๐Ÿ‡ง๐Ÿ‡ฏ

:BL:

๐Ÿ‡ง๐Ÿ‡ฑ

:BM:

๐Ÿ‡ง๐Ÿ‡ฒ

:BN:

๐Ÿ‡ง๐Ÿ‡ณ

:BO:

๐Ÿ‡ง๐Ÿ‡ด

:BQ:

๐Ÿ‡ง๐Ÿ‡ถ

:BR:

๐Ÿ‡ง๐Ÿ‡ท

:BS:

๐Ÿ‡ง๐Ÿ‡ธ

:BT:

๐Ÿ‡ง๐Ÿ‡น

:BV:

๐Ÿ‡ง๐Ÿ‡ป

:BW:

๐Ÿ‡ง๐Ÿ‡ผ

:BY:

๐Ÿ‡ง๐Ÿ‡พ

:BZ:

๐Ÿ‡ง๐Ÿ‡ฟ

:CA:

๐Ÿ‡จ๐Ÿ‡ฆ

:CC:

๐Ÿ‡จ๐Ÿ‡จ

:CD:

๐Ÿ‡จ๐Ÿ‡ฉ

:CF:

๐Ÿ‡จ๐Ÿ‡ซ

:CG:

๐Ÿ‡จ๐Ÿ‡ฌ

:CH:

๐Ÿ‡จ๐Ÿ‡ญ

:CI:

๐Ÿ‡จ๐Ÿ‡ฎ

:CK:

๐Ÿ‡จ๐Ÿ‡ฐ

:CL:

๐Ÿ‡จ๐Ÿ‡ฑ

:CM:

๐Ÿ‡จ๐Ÿ‡ฒ

:CN:

๐Ÿ‡จ๐Ÿ‡ณ

:CO:

๐Ÿ‡จ๐Ÿ‡ด

:CP:

๐Ÿ‡จ๐Ÿ‡ต

:CR:

๐Ÿ‡จ๐Ÿ‡ท

:CU:

๐Ÿ‡จ๐Ÿ‡บ

:CV:

๐Ÿ‡จ๐Ÿ‡ป

:CW:

๐Ÿ‡จ๐Ÿ‡ผ

:CX:

๐Ÿ‡จ๐Ÿ‡ฝ

:CY:

๐Ÿ‡จ๐Ÿ‡พ

:CZ:

๐Ÿ‡จ๐Ÿ‡ฟ

:DE:

๐Ÿ‡ฉ๐Ÿ‡ช

:DG:

๐Ÿ‡ฉ๐Ÿ‡ฌ

:DJ:

๐Ÿ‡ฉ๐Ÿ‡ฏ

:DK:

๐Ÿ‡ฉ๐Ÿ‡ฐ

:DM:

๐Ÿ‡ฉ๐Ÿ‡ฒ

:DO:

๐Ÿ‡ฉ๐Ÿ‡ด

:DZ:

๐Ÿ‡ฉ๐Ÿ‡ฟ

:EA:

๐Ÿ‡ช๐Ÿ‡ฆ

:EC:

๐Ÿ‡ช๐Ÿ‡จ

:EE:

๐Ÿ‡ช๐Ÿ‡ช

:EG:

๐Ÿ‡ช๐Ÿ‡ฌ

:EH:

๐Ÿ‡ช๐Ÿ‡ญ

:ER:

๐Ÿ‡ช๐Ÿ‡ท

:ES:

๐Ÿ‡ช๐Ÿ‡ธ

:ET:

๐Ÿ‡ช๐Ÿ‡น

:EU:

๐Ÿ‡ช๐Ÿ‡บ

:FI:

๐Ÿ‡ซ๐Ÿ‡ฎ

:FJ:

๐Ÿ‡ซ๐Ÿ‡ฏ

:FK:

๐Ÿ‡ซ๐Ÿ‡ฐ

:FM:

๐Ÿ‡ซ๐Ÿ‡ฒ

:FO:

๐Ÿ‡ซ๐Ÿ‡ด

:FR:

๐Ÿ‡ซ๐Ÿ‡ท

:GA:

๐Ÿ‡ฌ๐Ÿ‡ฆ

:GB:

๐Ÿ‡ฌ๐Ÿ‡ง

:GD:

๐Ÿ‡ฌ๐Ÿ‡ฉ

:GE:

๐Ÿ‡ฌ๐Ÿ‡ช

:GF:

๐Ÿ‡ฌ๐Ÿ‡ซ

:GG:

๐Ÿ‡ฌ๐Ÿ‡ฌ

:GH:

๐Ÿ‡ฌ๐Ÿ‡ญ

:GI:

๐Ÿ‡ฌ๐Ÿ‡ฎ

:GL:

๐Ÿ‡ฌ๐Ÿ‡ฑ

:GM:

๐Ÿ‡ฌ๐Ÿ‡ฒ

:GN:

๐Ÿ‡ฌ๐Ÿ‡ณ

:GP:

๐Ÿ‡ฌ๐Ÿ‡ต

:GQ:

๐Ÿ‡ฌ๐Ÿ‡ถ

:GR:

๐Ÿ‡ฌ๐Ÿ‡ท

:GS:

๐Ÿ‡ฌ๐Ÿ‡ธ

:GT:

๐Ÿ‡ฌ๐Ÿ‡น

:GU:

๐Ÿ‡ฌ๐Ÿ‡บ

:GW:

๐Ÿ‡ฌ๐Ÿ‡ผ

:GY:

๐Ÿ‡ฌ๐Ÿ‡พ

:HK:

๐Ÿ‡ญ๐Ÿ‡ฐ

:HM:

๐Ÿ‡ญ๐Ÿ‡ฒ

:HN:

๐Ÿ‡ญ๐Ÿ‡ณ

:HR:

๐Ÿ‡ญ๐Ÿ‡ท

:HT:

๐Ÿ‡ญ๐Ÿ‡น

:HU:

๐Ÿ‡ญ๐Ÿ‡บ

:IC:

๐Ÿ‡ฎ๐Ÿ‡จ

:ID:

๐Ÿ‡ฎ๐Ÿ‡ฉ

:IE:

๐Ÿ‡ฎ๐Ÿ‡ช

:IL:

๐Ÿ‡ฎ๐Ÿ‡ฑ

:IM:

๐Ÿ‡ฎ๐Ÿ‡ฒ

:IN:

๐Ÿ‡ฎ๐Ÿ‡ณ

:IO:

๐Ÿ‡ฎ๐Ÿ‡ด

:IQ:

๐Ÿ‡ฎ๐Ÿ‡ถ

:IR:

๐Ÿ‡ฎ๐Ÿ‡ท

:IS:

๐Ÿ‡ฎ๐Ÿ‡ธ

:IT:

๐Ÿ‡ฎ๐Ÿ‡น

:JE:

๐Ÿ‡ฏ๐Ÿ‡ช

:JM:

๐Ÿ‡ฏ๐Ÿ‡ฒ

:JO:

๐Ÿ‡ฏ๐Ÿ‡ด

:JP:

๐Ÿ‡ฏ๐Ÿ‡ต

:KE:

๐Ÿ‡ฐ๐Ÿ‡ช

:KG:

๐Ÿ‡ฐ๐Ÿ‡ฌ

:KH:

๐Ÿ‡ฐ๐Ÿ‡ญ

:KI:

๐Ÿ‡ฐ๐Ÿ‡ฎ

:KM:

๐Ÿ‡ฐ๐Ÿ‡ฒ

:KN:

๐Ÿ‡ฐ๐Ÿ‡ณ

:KP:

๐Ÿ‡ฐ๐Ÿ‡ต

:KR:

๐Ÿ‡ฐ๐Ÿ‡ท

:KW:

๐Ÿ‡ฐ๐Ÿ‡ผ

:KY:

๐Ÿ‡ฐ๐Ÿ‡พ

:KZ:

๐Ÿ‡ฐ๐Ÿ‡ฟ

:LA:

๐Ÿ‡ฑ๐Ÿ‡ฆ

:LB:

๐Ÿ‡ฑ๐Ÿ‡ง

:LC:

๐Ÿ‡ฑ๐Ÿ‡จ

:LI:

๐Ÿ‡ฑ๐Ÿ‡ฎ

:LK:

๐Ÿ‡ฑ๐Ÿ‡ฐ

:LR:

๐Ÿ‡ฑ๐Ÿ‡ท

:LS:

๐Ÿ‡ฑ๐Ÿ‡ธ

:LT:

๐Ÿ‡ฑ๐Ÿ‡น

:LU:

๐Ÿ‡ฑ๐Ÿ‡บ

:LV:

๐Ÿ‡ฑ๐Ÿ‡ป

:LY:

๐Ÿ‡ฑ๐Ÿ‡พ

:MA:

๐Ÿ‡ฒ๐Ÿ‡ฆ

:MC:

๐Ÿ‡ฒ๐Ÿ‡จ

:MD:

๐Ÿ‡ฒ๐Ÿ‡ฉ

:ME:

๐Ÿ‡ฒ๐Ÿ‡ช

:MF:

๐Ÿ‡ฒ๐Ÿ‡ซ

:MG:

๐Ÿ‡ฒ๐Ÿ‡ฌ

:MH:

๐Ÿ‡ฒ๐Ÿ‡ญ

:MK:

๐Ÿ‡ฒ๐Ÿ‡ฐ

:ML:

๐Ÿ‡ฒ๐Ÿ‡ฑ

:MM:

๐Ÿ‡ฒ๐Ÿ‡ฒ

:MN:

๐Ÿ‡ฒ๐Ÿ‡ณ

:MO:

๐Ÿ‡ฒ๐Ÿ‡ด

:MP:

๐Ÿ‡ฒ๐Ÿ‡ต

:MQ:

๐Ÿ‡ฒ๐Ÿ‡ถ

:MR:

๐Ÿ‡ฒ๐Ÿ‡ท

:MS:

๐Ÿ‡ฒ๐Ÿ‡ธ

:MT:

๐Ÿ‡ฒ๐Ÿ‡น

:MU:

๐Ÿ‡ฒ๐Ÿ‡บ

:MV:

๐Ÿ‡ฒ๐Ÿ‡ป

:MW:

๐Ÿ‡ฒ๐Ÿ‡ผ

:MX:

๐Ÿ‡ฒ๐Ÿ‡ฝ

:MY:

๐Ÿ‡ฒ๐Ÿ‡พ

:MZ:

๐Ÿ‡ฒ๐Ÿ‡ฟ

:NA:

๐Ÿ‡ณ๐Ÿ‡ฆ

:NC:

๐Ÿ‡ณ๐Ÿ‡จ

:NE:

๐Ÿ‡ณ๐Ÿ‡ช

:NF:

๐Ÿ‡ณ๐Ÿ‡ซ

:NG:

๐Ÿ‡ณ๐Ÿ‡ฌ

:NI:

๐Ÿ‡ณ๐Ÿ‡ฎ

:NL:

๐Ÿ‡ณ๐Ÿ‡ฑ

:NO:

๐Ÿ‡ณ๐Ÿ‡ด

:NP:

๐Ÿ‡ณ๐Ÿ‡ต

:NR:

๐Ÿ‡ณ๐Ÿ‡ท

:NU:

๐Ÿ‡ณ๐Ÿ‡บ

:NZ:

๐Ÿ‡ณ๐Ÿ‡ฟ

:OM:

๐Ÿ‡ด๐Ÿ‡ฒ

:PA:

๐Ÿ‡ต๐Ÿ‡ฆ

:PE:

๐Ÿ‡ต๐Ÿ‡ช

:PF:

๐Ÿ‡ต๐Ÿ‡ซ

:PG:

๐Ÿ‡ต๐Ÿ‡ฌ

:PH:

๐Ÿ‡ต๐Ÿ‡ญ

:PK:

๐Ÿ‡ต๐Ÿ‡ฐ

:PL:

๐Ÿ‡ต๐Ÿ‡ฑ

:PM:

๐Ÿ‡ต๐Ÿ‡ฒ

:PN:

๐Ÿ‡ต๐Ÿ‡ณ

:PR:

๐Ÿ‡ต๐Ÿ‡ท

:PS:

๐Ÿ‡ต๐Ÿ‡ธ

:PT:

๐Ÿ‡ต๐Ÿ‡น

:PW:

๐Ÿ‡ต๐Ÿ‡ผ

:PY:

๐Ÿ‡ต๐Ÿ‡พ

:QA:

๐Ÿ‡ถ๐Ÿ‡ฆ

:RE:

๐Ÿ‡ท๐Ÿ‡ช

:RO:

๐Ÿ‡ท๐Ÿ‡ด

:RS:

๐Ÿ‡ท๐Ÿ‡ธ

:RU:

๐Ÿ‡ท๐Ÿ‡บ

:RW:

๐Ÿ‡ท๐Ÿ‡ผ

:SA:

๐Ÿ‡ธ๐Ÿ‡ฆ

:SB:

๐Ÿ‡ธ๐Ÿ‡ง

:SC:

๐Ÿ‡ธ๐Ÿ‡จ

:SD:

๐Ÿ‡ธ๐Ÿ‡ฉ

:SE:

๐Ÿ‡ธ๐Ÿ‡ช

:SG:

๐Ÿ‡ธ๐Ÿ‡ฌ

:SH:

๐Ÿ‡ธ๐Ÿ‡ญ

:SI:

๐Ÿ‡ธ๐Ÿ‡ฎ

:SJ:

๐Ÿ‡ธ๐Ÿ‡ฏ

:SK:

๐Ÿ‡ธ๐Ÿ‡ฐ

:SL:

๐Ÿ‡ธ๐Ÿ‡ฑ

:SM:

๐Ÿ‡ธ๐Ÿ‡ฒ

:SN:

๐Ÿ‡ธ๐Ÿ‡ณ

:SO:

๐Ÿ‡ธ๐Ÿ‡ด

:SR:

๐Ÿ‡ธ๐Ÿ‡ท

:SS:

๐Ÿ‡ธ๐Ÿ‡ธ

:ST:

๐Ÿ‡ธ๐Ÿ‡น

:SV:

๐Ÿ‡ธ๐Ÿ‡ป

:SX:

๐Ÿ‡ธ๐Ÿ‡ฝ

:SY:

๐Ÿ‡ธ๐Ÿ‡พ

:SZ:

๐Ÿ‡ธ๐Ÿ‡ฟ

:TA:

๐Ÿ‡น๐Ÿ‡ฆ

:TC:

๐Ÿ‡น๐Ÿ‡จ

:TD:

๐Ÿ‡น๐Ÿ‡ฉ

:TF:

๐Ÿ‡น๐Ÿ‡ซ

:TG:

๐Ÿ‡น๐Ÿ‡ฌ

:TH:

๐Ÿ‡น๐Ÿ‡ญ

:TJ:

๐Ÿ‡น๐Ÿ‡ฏ

:TK:

๐Ÿ‡น๐Ÿ‡ฐ

:TL:

๐Ÿ‡น๐Ÿ‡ฑ

:TM:

๐Ÿ‡น๐Ÿ‡ฒ

:TN:

๐Ÿ‡น๐Ÿ‡ณ

:TO:

๐Ÿ‡น๐Ÿ‡ด

:TR:

๐Ÿ‡น๐Ÿ‡ท

:TT:

๐Ÿ‡น๐Ÿ‡น

:TV:

๐Ÿ‡น๐Ÿ‡ป

:TW:

๐Ÿ‡น๐Ÿ‡ผ

:TZ:

๐Ÿ‡น๐Ÿ‡ฟ

:UA:

๐Ÿ‡บ๐Ÿ‡ฆ

:UG:

๐Ÿ‡บ๐Ÿ‡ฌ

:UM:

๐Ÿ‡บ๐Ÿ‡ฒ

:US:

๐Ÿ‡บ๐Ÿ‡ธ

:UY:

๐Ÿ‡บ๐Ÿ‡พ

:UZ:

๐Ÿ‡บ๐Ÿ‡ฟ

:VA:

๐Ÿ‡ป๐Ÿ‡ฆ

:VC:

๐Ÿ‡ป๐Ÿ‡จ

:VE:

๐Ÿ‡ป๐Ÿ‡ช

:VG:

๐Ÿ‡ป๐Ÿ‡ฌ

:VI:

๐Ÿ‡ป๐Ÿ‡ฎ

:VN:

๐Ÿ‡ป๐Ÿ‡ณ

:VU:

๐Ÿ‡ป๐Ÿ‡บ

:WF:

๐Ÿ‡ผ๐Ÿ‡ซ

:WS:

๐Ÿ‡ผ๐Ÿ‡ธ

:XK:

๐Ÿ‡ฝ๐Ÿ‡ฐ

:YE:

๐Ÿ‡พ๐Ÿ‡ช

:YT:

๐Ÿ‡พ๐Ÿ‡น

:ZA:

๐Ÿ‡ฟ๐Ÿ‡ฆ

:ZM:

๐Ÿ‡ฟ๐Ÿ‡ฒ

:ZW:

๐Ÿ‡ฟ๐Ÿ‡ผ

Subregional flags๏ƒ

The only widely supported subregional flags are currently: England, Scotland and Wales (as of iOS 12 and Android 9).

Code

Emoji

:gb-sct:

๐Ÿด๓ ง๓ ข๓ ณ๓ ฃ๓ ด๓ ฟ

:gb-wls:

๐Ÿด๓ ง๓ ข๓ ท๓ ฌ๓ ณ๓ ฟ

:gb-eng:

๐Ÿด๓ ง๓ ข๓ ฅ๓ ฎ๓ ง๓ ฟ

:us-tx:

๐Ÿด๓ ต๓ ณ๓ ด๓ ธ๓ ฟ

WhatsApp offers one other state flag: Texas.
If you use WhatsAppโ€™s emoji panel to select the Texas flag, WhatsApp uses ๐Ÿ‡ฝ๐Ÿ‡น i.e. flagize(โ€œ:XT:โ€) for Texas. This code โ€œXTโ€ is specified by Unicode as โ€œexcludedโ€ meaning it is explicitly for private use and can be defined by anyone. Therefore, it is likely not displayed as the Texas flag on other platforms.
But WhatsApp also recognizes the flag emoji tag sequence flagize(โ€œ:us-tx:โ€, subregions=True) and displays the same flag.

How subregional flags work๏ƒ

They work very similar to the country flags. The ASCII codes are transformed by replacing them with specific codepoints that are called โ€œtagsโ€.

The basic format for a tag flag is:
black_flag_emoji followed by region_code_in_tag followed by cancel_tag

Note

black_flag_emoji:

U+1F3F4 ( ๐Ÿด )

cancel_tag:

U+E007F (invisible, signifies the end of the flag code)

region_code_in_tag:

It is formed using the abbreviation defined in ISO 3166-2 and adding 0xE0000 to every ASCII value of the code. For example England is GB-ENG.

A full list of valid codes can be found here: github.com/unicode-org/โ€ฆ/subdivisions/en.xml

Itโ€™s also possible to use a 3-digit-code from github.com/unicode-org/โ€ฆ/UnMacroRegions.txt

Example:๏ƒ

England is GB-ENG in ISO 3166-2.
We drop the hyphen and make it lowercase to get gbeng.
To transform this to โ€œtagsโ€, we need to add the value 0xE0000 = 917504 to every unicode value of gbeng:
g is unicode 0x67 or decimal 103, so 103 + 917504 = 917607 or 0xE0067
b is 0x62 and becomes 0xE0062
e is 0x65 and becomes 0xE0065
n is 0x6E and becomes 0xE006E
g is 0x67 and becomes 0xE0067

Together itโ€™s:

                      g        b        e        n        g
ASCII:                0x67     0x62     0x65     0x6E     0x67
Tags:   0x1F3F4    0xE0067  0xE0062  0xE0065  0xE006E  0xE0067  0xE007F
        black_flag                                             cancel_tag

Unlike the regional indicator symbols, tags are not rendered on incompatible system, they will simply be invisible and have no width. So, if the particular flag is not supported or if tag flags are not supported at all, the only visible character will be a black flag.

Indices and tables๏ƒ