Created
August 28, 2012 22:30
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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