INNER CODE UNIT · Python
character_payload
lean-dojo/TorchLean · scripts/generate_unicode_table.py:62
def character_payload(codepoint: int) -> int:
"""Encode the flags together with the decimal zero for interval splitting.
Decimal digits with different zero characters must land in different
intervals so that the digit value is the offset from the interval start.
"""
flags = character_flags(codepoint)
decimal_value = unicodedata.decimal(chr(codepoint), None)
if decimal_value is None:
return flags
return flags | 16 * (codepoint - decimal_value + 1)
def property_intervals() -> list[tuple[int, int, int]]:
"""Coalesce equal nonzero payloads, keeping decimal alphabets separate."""
intervals: list[tuple[int, int, int]] = []
interval_start = 0
current_payload = character_payload(0)