En/Decode unicode country flags emoji
Project description
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 CZ is Czechia: 🇨 + 🇿 = 🇨🇿
So, to encode an ASCII code like :NR:
to 🇳🇷, we just need to convert the ASCII N and R to the corresponding regional indicator symbols 🇳 and 🇷.
To reverse it, we translate the regional indicator symbols back to ASCII letters.
Example
>>> import flag
>>> flag.flagize("Flag of Israel :IL:")
'Flag of Israel 🇮🇱'
>>> flag.dflagize(u"Flag of Israel 🇮🇱")
'Flag of Israel :IL:'
Install
pip install emoji-country-flag
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for emoji_country_flag-1.0.1-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7636c115247525fe753df25b8b19e1a8cc3e93d563187142e0e982bc40eec417 |
|
MD5 | a1ea65c9fb03c566e048a2a1bb361bcc |
|
BLAKE2b-256 | 1f3cbbb727bb5ddbc9f77805e8d22d0f24f0f70eb792d6dc807c07e3721423a0 |