Ada 4.1.1
Fast spec-compliant URL parser
Loading...
Searching...
No Matches
mapping_tables.cpp
Go to the documentation of this file.
1// IDNA 18.0.0
2// Two-level compressed mapping table (constants only).
3// Array payloads are stored in the DEFLATE blob (see table_store.hpp /
4// scripts/pack_tables.py).
5// Regenerate with: python3 scripts/idna_table.py --write
6// Logical table size: 51037 bytes (49.8 KB)
7// stage1: 8162 bytes (4081 uint16_t entries)
8// stage2: 23424 bytes (183 mixed blocks x 64)
9// bool_blocks: 1800 bytes (225 uint64_t words)
10// utf8 maps: 17651 bytes
11
12// clang-format off
13#ifndef ADA_IDNA_MAPPING_TABLE_H
14#define ADA_IDNA_MAPPING_TABLE_H
15#include <cstdint>
16
17namespace ada::idna {
18
19// Block size for two-level table (2^6 = 64 code points per block).
20constexpr uint32_t IDNA_BLOCK_BITS = 6u;
21constexpr uint32_t IDNA_BLOCK_SIZE = 64u;
22constexpr uint32_t IDNA_BLOCK_MASK = 63u;
23
24// Sentinel values stored in stage2 / returned by lookup.
25constexpr uint16_t IDNA_VALID = 0xFFFF; // code point is valid as-is
26constexpr uint16_t IDNA_DISALLOWED = 0xFFFE; // code point is disallowed
27constexpr uint16_t IDNA_IGNORED = 0x0000; // ignored (index into empty UTF-8 entry)
28
29// Bit 15 of a stage1 entry: set = boolean block, clear = mixed block.
30constexpr uint16_t IDNA_BOOL_FLAG = 0x8000;
31
32// Two-level table covers code points [0, IDNA_LOW_RANGE_END).
33// Derived from the highest non-disallowed code point below the high-ignored range,
34// rounded up to the next 64-code-point block boundary.
35constexpr uint32_t IDNA_LOW_RANGE_END = 0x0003FC40;
36
37// Variation selectors supplement: U+E0100..U+E01EF are all ignored.
38// These are handled with a simple range check; everything else above
39// IDNA_LOW_RANGE_END is disallowed.
40constexpr uint32_t IDNA_HIGH_IGNORED_START = 0x000E0100;
41constexpr uint32_t IDNA_HIGH_IGNORED_END = 0x000E01F0; // exclusive
42
43// Large arrays (idna_stage1/stage2/bool_blocks/utf8_mappings) live in table_blob.
44
45} // namespace ada::idna
46#endif // ADA_IDNA_MAPPING_TABLE_H
constexpr uint32_t IDNA_BLOCK_MASK
constexpr uint16_t IDNA_BOOL_FLAG
constexpr uint32_t IDNA_BLOCK_BITS
constexpr uint32_t IDNA_BLOCK_SIZE
constexpr uint16_t IDNA_VALID
constexpr uint32_t IDNA_HIGH_IGNORED_START
constexpr uint32_t IDNA_LOW_RANGE_END
constexpr uint16_t IDNA_IGNORED
constexpr uint32_t IDNA_HIGH_IGNORED_END
constexpr uint16_t IDNA_DISALLOWED