Skip to main content

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

Metadata

Release files for emoji-country-flag 1.2.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for emoji-country-flag 1.2.3
File Size Uploaded
emoji-country-flag-1.2.3.tar.gz 6.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for emoji-country-flag 1.2.3
File Interpreter ABI Platform
emoji_country_flag-1.2.3-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 13.7 kB

Release files / emoji-country-flag-1.2.3.tar.gz

Download URL emoji-country-flag-1.2.3.tar.gz
Size 6.4 kB
Tags Source
SHA-256 checksum
How to use checksums
256e47d30fb43bf154f370cc3c9e767f003aeb8653e31ba7b87151669c608e19
BLAKE2b-256 checksum
How to use checksums
ba129670dee7b9713be9e2fbf590bfc2b910be5d8d300411bf9fefc37e50a2e6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.9.0

Release files / emoji_country_flag-1.2.3-py2.py3-none-any.whl

Download URL emoji_country_flag-1.2.3-py2.py3-none-any.whl
Size 7.3 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
3f6c32699c19489383497865b208260b1d55b8424d66e08049187b13db2f0b8a
BLAKE2b-256 checksum
How to use checksums
b00ac37a9c95b2bc70913d8c2c9ed98aaa9becb5ec9872111d6960a8f870468a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.9.0

Release history Release notifications | RSS feed

2.1.0

2 release files

2.0.1

2 release files

2.0.0

2 release files

1.3.2

2 release files

1.3.1

2 release files

1.3.0

2 release files

1.2.4

2 release files

This release

1.2.3 This release

2 release files

1.2.1

2 release files

1.2.0

2 release files

1.1.0

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page