Skip to content

Instantly share code, notes, and snippets.

@sammachin
sammachin / country_code_to_emoji_extras.py
Created October 21, 2016 19:59 — forked from linville/country_code_to_emoji_extras.py
Django template converts country code to Emoji
from django import template
register = template.Library()
OFFSET = ord('🇦') - ord('A')
@register.filter
def flag(code):
return chr(ord(code[0]) + OFFSET) + chr(ord(code[1]) + OFFSET)
# Example:
# flag("US") = "🇺🇸"