Loma  Baumbach

Loma Baumbach

1624525361

Flag Emoji from Country Codes for Python

flag

Flag emoji for Python.
Converts flag emoji to ASCII and other way round.

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

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 W to the corresponding regional indicator symbols 🇹 and 🇼.
To reverse it, we translate the regional indicator symbols back to ASCII letters.

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/

Python 3.6 or higher is required for the latest release. The last release for Python 2.7, 3.4 and 3.5 was v1.2.4.

Download Details:

Author: cvzi
The Demo/Documentation: View The Demo/Documentation
Download Link: Download The Source Code
Official Website: https://github.com/cvzi/flag
License: MIT

#python

Flag Emoji from Country Codes for Python