source: other-projects/metadata-encoding/py/comparisonTest/pyicu-unicode-block-names.py@ 38791

Last change on this file since 38791 was 38791, checked in by jc550, 4 months ago

add comments adding context to functions that require it

File size: 503 bytes
Line 
1# Created by Chris Adams, source (https://gist.github.com/acdha/49a610089c2798db6fe2)
2
3import icu
4
5# Astoundingly, PyICU has no documented way to get a Unicode block name.
6# There are two ways to get the offset into the UCodeBlock enum
7# – icu.Char.ublock_getCode and icu.Char.getIntPropertyValue(
, icu.UProperty.BLOCK) –
8# so we'll build a lookup table to turn that into a human-readable string:
9
10UNICODE_BLOCKS = {getattr(icu.UBlockCode, i): i for i in icu.UBlockCode.__dict__ if i.isupper()}
Note: See TracBrowser for help on using the repository browser.