Ada 4.1.1
Fast spec-compliant URL parser
Loading...
Searching...
No Matches
idna_table Namespace Reference

Functions

 get_table ()
 get_version (table_data)
 encode_utf8 (cp)
 parse_idna (table_data)
 find_high_ignored_range (entries)
 compute_low_range_end (entries, high_ignored_start)
 build_flat_and_mappings (entries, low_range_end)
 build_two_level (flat)
 hex2 (v)
 hex4 (v)
 hex8 (v)
 hex16 (v)
 emit_array_uint8 (name, data, cols=16)
 emit_array_uint16 (name, data, cols=12)
 emit_array_uint64 (name, data, cols=4)
 generate_idna ()
 print_idna ()
 write_idna ()

Variables

int BLOCK_BITS = 6
int BLOCK_SIZE = 1 << BLOCK_BITS
int BLOCK_MASK = BLOCK_SIZE - 1
int BOOL_FLAG = 0x8000
int SENTINEL_VALID = 0xFFFF
int SENTINEL_DISALLOWED = 0xFFFE
int IGNORED_IDX = 0
str UNICODE_VERSION = "18.0.0"
str url = f"https://www.unicode.org/Public/{UNICODE_VERSION}/idna/IdnaMappingTable.txt"
str filename = f"IdnaMappingTable-{UNICODE_VERSION}.txt"

Function Documentation

◆ build_flat_and_mappings()

build_flat_and_mappings ( entries,
low_range_end )
Returns (flat, utf8_table, seq_to_idx) where
  flat[cp] = SENTINEL_VALID | SENTINEL_DISALLOWED | utf8_byte_offset
  utf8_table = bytearray of null-terminated UTF-8 mapping strings
  seq_to_idx = dict mapping tuple of codepoints -> byte offset in utf8_table

Definition at line 130 of file idna_table.py.

References encode_utf8().

Referenced by generate_idna().

◆ build_two_level()

build_two_level ( flat)
Returns (stage1, mixed_data, bool_words) where
  stage1[i] = index for block i
    bit 15 set  -> bool block: lower 15 bits = bool_block_idx
    bit 15 clear -> mixed block: value = base offset into mixed_data[]
  mixed_data = flat uint16_t array (all mixed blocks concatenated)
  bool_words = list of uint64_t bitwords; bit k=1 ↔ code point is VALID

Definition at line 173 of file idna_table.py.

Referenced by generate_idna().

◆ compute_low_range_end()

compute_low_range_end ( entries,
high_ignored_start )
Find the first block boundary that covers all non-disallowed code points
below the high-ignored range.  This dynamically captures the full active
range (including CJK Extension I/J and similar future additions) without
requiring any hardcoded boundaries.

Definition at line 109 of file idna_table.py.

Referenced by generate_idna().

◆ emit_array_uint16()

emit_array_uint16 ( name,
data,
cols = 12 )

Definition at line 238 of file idna_table.py.

References hex4().

Referenced by print_idna().

◆ emit_array_uint64()

emit_array_uint64 ( name,
data,
cols = 4 )

Definition at line 251 of file idna_table.py.

References hex16().

Referenced by print_idna().

◆ emit_array_uint8()

emit_array_uint8 ( name,
data,
cols = 16 )

Definition at line 225 of file idna_table.py.

References hex2().

Referenced by print_idna().

◆ encode_utf8()

encode_utf8 ( cp)
Return UTF-8 encoding of a Unicode code point as bytes.

Definition at line 45 of file idna_table.py.

Referenced by build_flat_and_mappings().

◆ find_high_ignored_range()

find_high_ignored_range ( entries)
Find the ignored code point range above U+E0000.
Returns (start, end_exclusive) or (None, None) if not found.

Definition at line 97 of file idna_table.py.

Referenced by generate_idna().

◆ generate_idna()

generate_idna ( )
Build mapping tables from IdnaMappingTable.txt.

Returns a dict with constants and array payloads suitable for packing.

Definition at line 265 of file idna_table.py.

References build_flat_and_mappings(), build_two_level(), compute_low_range_end(), find_high_ignored_range(), get_table(), get_version(), and parse_idna().

Referenced by print_idna(), and write_idna().

◆ get_table()

get_table ( )

Definition at line 27 of file idna_table.py.

References get_version().

Referenced by generate_idna().

◆ get_version()

get_version ( table_data)

Definition at line 41 of file idna_table.py.

Referenced by generate_idna(), and get_table().

◆ hex16()

hex16 ( v)

Definition at line 223 of file idna_table.py.

Referenced by emit_array_uint64().

◆ hex2()

hex2 ( v)

Definition at line 220 of file idna_table.py.

Referenced by emit_array_uint8().

◆ hex4()

hex4 ( v)

Definition at line 221 of file idna_table.py.

Referenced by emit_array_uint16().

◆ hex8()

hex8 ( v)

Definition at line 222 of file idna_table.py.

◆ parse_idna()

parse_idna ( table_data)
Returns a list of (cp_start, cp_end_inclusive, code, mapped_seq) where
  code = 0 ignored | 1 valid | 2 disallowed | 3 mapped
  mapped_seq = tuple of uint32 code points (only when code==3)

Definition at line 63 of file idna_table.py.

Referenced by generate_idna().

◆ print_idna()

print_idna ( )
Print expanded C++ arrays to stdout (debug / legacy).

Definition at line 311 of file idna_table.py.

References emit_array_uint16(), emit_array_uint64(), emit_array_uint8(), and generate_idna().

Referenced by write_idna().

◆ write_idna()

write_idna ( )
Write constants to src/mapping_tables.cpp and update table_blob.inc.

Definition at line 400 of file idna_table.py.

References generate_idna(), print_idna(), pack_tables.update_mapping_in_blob(), write_idna(), and pack_tables.write_mapping_constants().

Referenced by write_idna().

Variable Documentation

◆ BLOCK_BITS

int idna_table.BLOCK_BITS = 6

Definition at line 10 of file idna_table.py.

◆ BLOCK_MASK

int idna_table.BLOCK_MASK = BLOCK_SIZE - 1

Definition at line 12 of file idna_table.py.

◆ BLOCK_SIZE

int idna_table.BLOCK_SIZE = 1 << BLOCK_BITS

Definition at line 11 of file idna_table.py.

◆ BOOL_FLAG

int idna_table.BOOL_FLAG = 0x8000

Definition at line 13 of file idna_table.py.

◆ filename

str idna_table.filename = f"IdnaMappingTable-{UNICODE_VERSION}.txt"

Definition at line 25 of file idna_table.py.

◆ IGNORED_IDX

int idna_table.IGNORED_IDX = 0

Definition at line 18 of file idna_table.py.

◆ SENTINEL_DISALLOWED

int idna_table.SENTINEL_DISALLOWED = 0xFFFE

Definition at line 16 of file idna_table.py.

◆ SENTINEL_VALID

int idna_table.SENTINEL_VALID = 0xFFFF

Definition at line 15 of file idna_table.py.

◆ UNICODE_VERSION

str idna_table.UNICODE_VERSION = "18.0.0"

Definition at line 23 of file idna_table.py.

◆ url

str idna_table.url = f"https://www.unicode.org/Public/{UNICODE_VERSION}/idna/IdnaMappingTable.txt"

Definition at line 24 of file idna_table.py.