Return the Unicode block of the given Unicode character
(cls, uni_char)
| 380 | |
| 381 | @classmethod |
| 382 | def get(cls, uni_char): |
| 383 | """Return the Unicode block of the given Unicode character""" |
| 384 | uni_char = unicod(uni_char) # Force to Unicode |
| 385 | code_point = ord(uni_char) |
| 386 | if Block._RANGE_KEYS is None: |
| 387 | Block._RANGE_KEYS = sorted(Block._RANGES.keys()) |
| 388 | idx = bisect.bisect_left(Block._RANGE_KEYS, code_point) |
| 389 | if (idx > 0 and |
| 390 | code_point >= Block._RANGES[Block._RANGE_KEYS[idx - 1]].start and |
| 391 | code_point <= Block._RANGES[Block._RANGE_KEYS[idx - 1]].end): |
| 392 | return Block._RANGES[Block._RANGE_KEYS[idx - 1]] |
| 393 | elif (idx < len(Block._RANGES) and |
| 394 | code_point >= Block._RANGES[Block._RANGE_KEYS[idx]].start and |
| 395 | code_point <= Block._RANGES[Block._RANGE_KEYS[idx]].end): |
| 396 | return Block._RANGES[Block._RANGE_KEYS[idx]] |
| 397 | else: |
| 398 | return Block.UNKNOWN |
| 399 | |
| 400 | |
| 401 | def digit(uni_char, default_value=None): |
no outgoing calls
no test coverage detected