Skip to main content

En/Decode unicode country flags emoji

Project description

flag

foodemoji on PyPI Python Versions Coverage Status Build Status Documentation Status Codacy Badge Maintainability

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

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

emoji-country-flag-1.0.1.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

emoji_country_flag-1.0.1-py2.py3-none-any.whl (5.2 kB view details)

Uploaded Python 2Python 3

File details

Details for the file emoji-country-flag-1.0.1.tar.gz.

File metadata

  • Download URL: emoji-country-flag-1.0.1.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2

File hashes

Hashes for emoji-country-flag-1.0.1.tar.gz
Algorithm Hash digest
SHA256 534c1582d07cf980b9e6da39251b1c638c5ec949eeba58a19d00a93985261378
MD5 8ae6da2327b1a7022c2e9900a7c3fd4d
BLAKE2b-256 19fff6c8e2a2aa96b1ec8045b54a10af6967cc69cd46a57bc5585d20130d5cab

See more details on using hashes here.

File details

Details for the file emoji_country_flag-1.0.1-py2.py3-none-any.whl.

File metadata

  • Download URL: emoji_country_flag-1.0.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 5.2 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2

File hashes

Hashes for emoji_country_flag-1.0.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 7636c115247525fe753df25b8b19e1a8cc3e93d563187142e0e982bc40eec417
MD5 a1ea65c9fb03c566e048a2a1bb361bcc
BLAKE2b-256 1f3cbbb727bb5ddbc9f77805e8d22d0f24f0f70eb792d6dc807c07e3721423a0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page