Skip to content

Instantly share code, notes, and snippets.

@acdha
Created August 28, 2012 22:30
Show Gist options
  • Select an option

  • Save acdha/3504932 to your computer and use it in GitHub Desktop.

Select an option

Save acdha/3504932 to your computer and use it in GitHub Desktop.
Demonstration using Python's unicodedata module to determine decimal value of characters by reporting
#!/usr/bin/env python
"""Unicode decimal value example: print everything numerically equal to 5"""
from __future__ import print_function, unicode_literals
from unicodedata import decimal
import sys
if sys.version_info[0] == 3:
unichr = chr
# Note the use of maxunicode to avoid issues on Python 2.x narrow builds
# (see http://www.python.org/dev/peps/pep-0261/)
for i in range(0, sys.maxunicode):
u = unichr(i)
if decimal(u, None) == 5:
print(u.encode("utf-8"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment