Skip to main content

En/Decode unicode country flags emoji

Project description

flag

foodemoji on PyPI Python Versions Coverage Status Build Status Codacy Badge Maintainability Quality Gate Status

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.flag("IL")
    '🇮🇱'

    >>> flag.flag("GBENG")
    '🏴󠁧󠁢󠁥󠁮󠁧󠁿 '

    >>> flag.flagize("Flag of Israel :IL:")
    'Flag of Israel 🇮🇱'

    >>> flag.dflagize(u"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(u"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/

Documentation

Documentation Status

Documentation at https://flag.readthedocs.io

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.2.1.tar.gz (6.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

emoji_country_flag-1.2.1-py2.py3-none-any.whl (7.3 kB view details)

Uploaded Python 2Python 3

File details

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

File metadata

  • Download URL: emoji-country-flag-1.2.1.tar.gz
  • Upload date:
  • Size: 6.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.42.0 CPython/3.8.1

File hashes

Hashes for emoji-country-flag-1.2.1.tar.gz
Algorithm Hash digest
SHA256 ae7edb38077b0840210fa9e37673f481f2b9c032446e13ad6dab2b1108cd7ad6
MD5 32c000750d8d92d96d5350b8e09b4f47
BLAKE2b-256 2c22ce7a277fa1fa38fae72541de3b68153e053ee3d95fc975200263ac192b39

See more details on using hashes here.

File details

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

File metadata

  • Download URL: emoji_country_flag-1.2.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 7.3 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.42.0 CPython/3.8.1

File hashes

Hashes for emoji_country_flag-1.2.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 67c0cb6a3765fb53f31b34160d6b1c8a5f44b297bc278d1835c6f2e5b0a9a592
MD5 a72c89b3e2481c6a31ad989dcf2b17d7
BLAKE2b-256 55b49ccbd672151c79f1f00b9a6514ba4b64d3f05b3722269a3221b6b0d1401e

See more details on using hashes here.

Supported by

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