[New-bugs-announce] [issue22612] Add block info to unicodedata

flying sheep report at bugs.python.org
Sat Oct 11 19:58:45 CEST 2014


New submission from flying sheep:

See also #6331.

The repo https://github.com/nagisa/unicodeblocks contains pretty much the functionality i’d like to see: a way to get access to information about all blocks, and a way to get the block name a char is in.

I propose to include something very similar to those two APIs in unicodedata:

unicodedata.Block: class with start, end, and name property.

its __contains__ should work for single-char-strings (which tests if that char is in the block) and for ints (which tests if the codepoint is in the block)

maybe make it iterable over its chars?

unicodedata.blocks: OrderedDict of str (block name) → Block object mappings ordered by Block.start.

then blocks.keys() would yield the names in order, and blocks.values() the block objects in order.

unicodedata.block_of(chr, name_only=False): returns the Block object for which “chr in block” is True, or its name.

---

alternative: make the Block class an unfancy namedtuple without __contains__ method.

---

Together with #18234, fixing this bug will complete UnicodeData support in python, i guess.

----------
messages: 229101
nosy: flying sheep
priority: normal
severity: normal
status: open
title: Add block info to unicodedata
type: enhancement
versions: Python 3.5

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue22612>
_______________________________________


More information about the New-bugs-announce mailing list