Ada 2.9.2
Fast spec-compliant URL parser
Loading...
Searching...
No Matches
ada::idna Namespace Reference

Classes

struct  directions

Enumerations

enum  direction : uint8_t {
  NONE , BN , CS , ES ,
  ON , EN , L , R ,
  NSM , AL , AN , ET ,
  WS , RLO , LRO , PDF ,
  RLE , RLI , FSI , PDI ,
  LRI , B , S , LRE ,
  NONE , BN , CS , ES ,
  ON , EN , L , R ,
  NSM , AL , AN , ET ,
  WS , RLO , LRO , PDF ,
  RLE , RLI , FSI , PDI ,
  LRI , B , S , LRE
}
enum  direction : uint8_t {
  NONE , BN , CS , ES ,
  ON , EN , L , R ,
  NSM , AL , AN , ET ,
  WS , RLO , LRO , PDF ,
  RLE , RLI , FSI , PDI ,
  LRI , B , S , LRE ,
  NONE , BN , CS , ES ,
  ON , EN , L , R ,
  NSM , AL , AN , ET ,
  WS , RLO , LRO , PDF ,
  RLE , RLI , FSI , PDI ,
  LRI , B , S , LRE
}

Functions

size_t utf8_to_utf32 (const char *buf, size_t len, char32_t *utf32_output)
size_t utf8_length_from_utf32 (const char32_t *buf, size_t len)
size_t utf32_length_from_utf8 (const char *buf, size_t len)
size_t utf32_to_utf8 (const char32_t *buf, size_t len, char *utf8_output)
void ascii_map (char *input, size_t length)
bool ascii_has_upper_case (char *input, size_t length)
std::u32string map (std::u32string_view input)
void normalize (std::u32string &input)
bool punycode_to_utf32 (std::string_view input, std::u32string &out)
bool verify_punycode (std::string_view input)
bool utf32_to_punycode (std::u32string_view input, std::string &out)
bool is_label_valid (std::u32string_view label)
std::string to_ascii (std::string_view ut8_string)
bool contains_forbidden_domain_code_point (std::string_view ascii_string)
bool begins_with (std::u32string_view view, std::u32string_view prefix)
bool begins_with (std::string_view view, std::string_view prefix)
bool constexpr is_ascii (std::u32string_view view)
bool constexpr is_ascii (std::string_view view)
std::string to_unicode (std::string_view input)
uint32_t find_range_index (uint32_t key)
std::pair< bool, size_t > compute_decomposition_length (const std::u32string_view input) noexcept
void decompose (std::u32string &input, size_t additional_elements)
uint8_t get_ccc (char32_t c) noexcept
void sort_marks (std::u32string &input)
void decompose_nfc (std::u32string &input)
void compose (std::u32string &input)
static constexpr int32_t char_to_digit_value (char value)
static constexpr char digit_to_char (int32_t digit)
static constexpr int32_t adapt (int32_t d, int32_t n, bool firsttime)
static direction find_direction (uint32_t code_point) noexcept
static size_t find_last_not_of_nsm (const std::u32string_view label) noexcept
static bool is_rtl_label (const std::u32string_view label) noexcept
bool is_forbidden_domain_code_point (const char c) noexcept
static std::string from_ascii_to_ascii (std::string_view ut8_string)
static constexpr int32_t char_to_digit_value (char value)
static constexpr char digit_to_char (int32_t digit)
static constexpr int32_t adapt (int32_t d, int32_t n, bool firsttime)
static direction find_direction (uint32_t code_point) noexcept
static size_t find_last_not_of_nsm (const std::u32string_view label) noexcept
static bool is_rtl_label (const std::u32string_view label) noexcept
static std::string from_ascii_to_ascii (std::string_view ut8_string)

Variables

const uint32_t mappings [5164]
const uint32_t table [8000][2]
const uint8_t decomposition_index [4352]
const uint16_t decomposition_block [67][257]
const char32_t decomposition_data [9102]
const uint8_t canonical_combining_class_index [4352]
const uint8_t canonical_combining_class_block [67][256]
const uint8_t composition_index [4352]
const uint16_t composition_block [67][257]
const char32_t composition_data [1883]
constexpr char32_t hangul_sbase = 0xAC00
constexpr char32_t hangul_tbase = 0x11A7
constexpr char32_t hangul_vbase = 0x1161
constexpr char32_t hangul_lbase = 0x1100
constexpr char32_t hangul_lcount = 19
constexpr char32_t hangul_vcount = 21
constexpr char32_t hangul_tcount = 28
constexpr char32_t hangul_ncount = hangul_vcount * hangul_tcount
constexpr char32_t hangul_scount
constexpr int32_t base = 36
constexpr int32_t tmin = 1
constexpr int32_t tmax = 26
constexpr int32_t skew = 38
constexpr int32_t damp = 700
constexpr int32_t initial_bias = 72
constexpr uint32_t initial_n = 128
static directions dir_table []
static constexpr uint8_t is_forbidden_domain_code_point_table []
static directions dir_table []
static constexpr uint8_t is_forbidden_domain_code_point_table []

Detailed Description

Enumeration Type Documentation

◆ direction [1/2]

enum ada::idna::direction : uint8_t
Enumerator
NONE 
BN 
CS 
ES 
ON 
EN 
L 
R 
NSM 
AL 
AN 
ET 
WS 
RLO 
LRO 
PDF 
RLE 
RLI 
FSI 
PDI 
LRI 
B 
S 
LRE 
NONE 
BN 
CS 
ES 
ON 
EN 
L 
R 
NSM 
AL 
AN 
ET 
WS 
RLO 
LRO 
PDF 
RLE 
RLI 
FSI 
PDI 
LRI 
B 
S 
LRE 

Definition at line 8191 of file ada.cpp.

◆ direction [2/2]

enum ada::idna::direction : uint8_t
Enumerator
NONE 
BN 
CS 
ES 
ON 
EN 
L 
R 
NSM 
AL 
AN 
ET 
WS 
RLO 
LRO 
PDF 
RLE 
RLI 
FSI 
PDI 
LRI 
B 
S 
LRE 
NONE 
BN 
CS 
ES 
ON 
EN 
L 
R 
NSM 
AL 
AN 
ET 
WS 
RLO 
LRO 
PDF 
RLE 
RLI 
FSI 
PDI 
LRI 
B 
S 
LRE 

Definition at line 8056 of file ada_idna.cpp.

Function Documentation

◆ adapt() [1/2]

constexpr int32_t ada::idna::adapt ( int32_t d,
int32_t n,
bool firsttime )
staticconstexpr

Definition at line 7988 of file ada.cpp.

References base, damp, skew, tmax, and tmin.

Referenced by punycode_to_utf32(), utf32_to_punycode(), and verify_punycode().

◆ adapt() [2/2]

constexpr int32_t ada::idna::adapt ( int32_t d,
int32_t n,
bool firsttime )
staticconstexpr

Definition at line 7853 of file ada_idna.cpp.

References base, damp, skew, tmax, and tmin.

◆ ascii_has_upper_case()

bool ada::idna::ascii_has_upper_case ( char * input,
size_t length )

Definition at line 2755 of file ada.cpp.

Referenced by LLVMFuzzerTestOneInput().

◆ ascii_map()

void ada::idna::ascii_map ( char * input,
size_t length )

Definition at line 2779 of file ada.cpp.

Referenced by from_ascii_to_ascii().

◆ begins_with() [1/2]

bool ada::idna::begins_with ( std::string_view view,
std::string_view prefix )

Definition at line 9533 of file ada.cpp.

◆ begins_with() [2/2]

bool ada::idna::begins_with ( std::u32string_view view,
std::u32string_view prefix )

Definition at line 9525 of file ada.cpp.

Referenced by from_ascii_to_ascii(), to_ascii(), and to_unicode().

◆ char_to_digit_value() [1/2]

constexpr int32_t ada::idna::char_to_digit_value ( char value)
staticconstexpr

Definition at line 7978 of file ada.cpp.

Referenced by punycode_to_utf32(), and verify_punycode().

◆ char_to_digit_value() [2/2]

constexpr int32_t ada::idna::char_to_digit_value ( char value)
staticconstexpr

Definition at line 7843 of file ada_idna.cpp.

◆ compose()

void ada::idna::compose ( std::u32string & input)

◆ compute_decomposition_length()

std::pair< bool, size_t > ada::idna::compute_decomposition_length ( const std::u32string_view input)
noexcept

Definition at line 7765 of file ada.cpp.

References decomposition_block, decomposition_index, hangul_sbase, hangul_scount, and hangul_tcount.

Referenced by decompose_nfc().

◆ contains_forbidden_domain_code_point()

bool ada::idna::contains_forbidden_domain_code_point ( std::string_view ascii_string)

Definition at line 9578 of file ada.cpp.

References is_forbidden_domain_code_point().

◆ decompose()

void ada::idna::decompose ( std::u32string & input,
size_t additional_elements )

◆ decompose_nfc()

void ada::idna::decompose_nfc ( std::u32string & input)

Decompose the domain_name string to Unicode Normalization Form C.

See also
https://www.unicode.org/reports/tr46/#ProcessingStepDecompose

Definition at line 7859 of file ada.cpp.

References compute_decomposition_length(), decompose(), and sort_marks().

Referenced by normalize().

◆ digit_to_char() [1/2]

constexpr char ada::idna::digit_to_char ( int32_t digit)
staticconstexpr

Definition at line 7984 of file ada.cpp.

Referenced by utf32_to_punycode().

◆ digit_to_char() [2/2]

constexpr char ada::idna::digit_to_char ( int32_t digit)
staticconstexpr

Definition at line 7849 of file ada_idna.cpp.

◆ find_direction() [1/2]

direction ada::idna::find_direction ( uint32_t code_point)
inlinestaticnoexcept

Definition at line 8953 of file ada.cpp.

References dir_table, and ada::idna::directions::final_code.

Referenced by find_last_not_of_nsm(), is_label_valid(), and is_rtl_label().

◆ find_direction() [2/2]

direction ada::idna::find_direction ( uint32_t code_point)
inlinestaticnoexcept

Definition at line 8818 of file ada_idna.cpp.

References dir_table.

◆ find_last_not_of_nsm() [1/2]

size_t ada::idna::find_last_not_of_nsm ( const std::u32string_view label)
inlinestaticnoexcept

Definition at line 8969 of file ada.cpp.

References find_direction().

Referenced by is_label_valid().

◆ find_last_not_of_nsm() [2/2]

size_t ada::idna::find_last_not_of_nsm ( const std::u32string_view label)
inlinestaticnoexcept

Definition at line 8834 of file ada_idna.cpp.

References find_direction().

◆ find_range_index()

uint32_t ada::idna::find_range_index ( uint32_t key)

Definition at line 2733 of file ada.cpp.

References table.

Referenced by map().

◆ from_ascii_to_ascii() [1/2]

std::string ada::idna::from_ascii_to_ascii ( std::string_view ut8_string)
static

Definition at line 9584 of file ada.cpp.

References ascii_map(), begins_with(), is_label_valid(), map(), normalize(), and punycode_to_utf32().

Referenced by to_ascii().

◆ from_ascii_to_ascii() [2/2]

std::string ada::idna::from_ascii_to_ascii ( std::string_view ut8_string)
static

◆ get_ccc()

uint8_t ada::idna::get_ccc ( char32_t c)
noexcept

Definition at line 7837 of file ada.cpp.

References canonical_combining_class_block, and canonical_combining_class_index.

Referenced by compose(), and sort_marks().

◆ is_ascii() [1/2]

bool constexpr ada::idna::is_ascii ( std::string_view view)
constexpr

Definition at line 9550 of file ada.cpp.

◆ is_ascii() [2/2]

bool constexpr ada::idna::is_ascii ( std::u32string_view view)
constexpr

Definition at line 9541 of file ada.cpp.

Referenced by to_ascii(), and to_unicode().

◆ is_forbidden_domain_code_point()

bool ada::idna::is_forbidden_domain_code_point ( const char c)
inlinenoexcept

Definition at line 9574 of file ada.cpp.

References is_forbidden_domain_code_point_table.

Referenced by contains_forbidden_domain_code_point().

◆ is_label_valid()

bool ada::idna::is_label_valid ( std::u32string_view label)

◆ is_rtl_label() [1/2]

bool ada::idna::is_rtl_label ( const std::u32string_view label)
inlinestaticnoexcept

Definition at line 8979 of file ada.cpp.

References find_direction().

Referenced by is_label_valid().

◆ is_rtl_label() [2/2]

bool ada::idna::is_rtl_label ( const std::u32string_view label)
inlinestaticnoexcept

Definition at line 8844 of file ada_idna.cpp.

References find_direction().

◆ map()

std::u32string ada::idna::map ( std::u32string_view input)

Definition at line 2805 of file ada.cpp.

References find_range_index(), mappings, and table.

Referenced by from_ascii_to_ascii(), and to_ascii().

◆ normalize()

void ada::idna::normalize ( std::u32string & input)

Normalize the domain_name string to Unicode Normalization Form C.

See also
https://www.unicode.org/reports/tr46/#ProcessingStepNormalize

Definition at line 7953 of file ada.cpp.

References compose(), and decompose_nfc().

Referenced by from_ascii_to_ascii(), and to_ascii().

◆ punycode_to_utf32()

bool ada::idna::punycode_to_utf32 ( std::string_view input,
std::u32string & out )

Definition at line 8003 of file ada.cpp.

References adapt(), base, char_to_digit_value(), initial_bias, initial_n, and tmax.

Referenced by from_ascii_to_ascii(), to_ascii(), and to_unicode().

◆ sort_marks()

void ada::idna::sort_marks ( std::u32string & input)

Definition at line 7843 of file ada.cpp.

References get_ccc().

Referenced by decompose_nfc().

◆ to_ascii()

std::string ada::idna::to_ascii ( std::string_view ut8_string)

◆ to_unicode()

std::string ada::idna::to_unicode ( std::string_view input)

◆ utf32_length_from_utf8()

size_t ada::idna::utf32_length_from_utf8 ( const char * buf,
size_t len )

Definition at line 256 of file ada.cpp.

Referenced by to_ascii().

◆ utf32_to_punycode()

bool ada::idna::utf32_to_punycode ( std::u32string_view input,
std::string & out )

Definition at line 8122 of file ada.cpp.

References adapt(), base, digit_to_char(), initial_bias, initial_n, and tmax.

Referenced by to_ascii().

◆ utf32_to_utf8()

size_t ada::idna::utf32_to_utf8 ( const char32_t * buf,
size_t len,
char * utf8_output )

Definition at line 265 of file ada.cpp.

Referenced by to_unicode().

◆ utf8_length_from_utf32()

size_t ada::idna::utf8_length_from_utf32 ( const char32_t * buf,
size_t len )

Definition at line 243 of file ada.cpp.

Referenced by to_unicode().

◆ utf8_to_utf32()

size_t ada::idna::utf8_to_utf32 ( const char * buf,
size_t len,
char32_t * utf32_output )

Definition at line 146 of file ada.cpp.

Referenced by to_ascii().

◆ verify_punycode()

bool ada::idna::verify_punycode ( std::string_view input)

Definition at line 8064 of file ada.cpp.

References adapt(), base, char_to_digit_value(), initial_bias, initial_n, and tmax.

Referenced by to_unicode().

Variable Documentation

◆ base

int32_t ada::idna::base = 36
constexpr

Definition at line 7970 of file ada.cpp.

Referenced by adapt(), punycode_to_utf32(), utf32_to_punycode(), and verify_punycode().

◆ canonical_combining_class_block

const uint8_t ada::idna::canonical_combining_class_block

Definition at line 5991 of file ada.cpp.

Referenced by get_ccc().

◆ canonical_combining_class_index

const uint8_t ada::idna::canonical_combining_class_index

Definition at line 5760 of file ada.cpp.

Referenced by get_ccc().

◆ composition_block

const uint16_t ada::idna::composition_block

Definition at line 7066 of file ada.cpp.

Referenced by compose().

◆ composition_data

const char32_t ada::idna::composition_data

Definition at line 7572 of file ada.cpp.

Referenced by compose().

◆ composition_index

const uint8_t ada::idna::composition_index

Definition at line 6867 of file ada.cpp.

Referenced by compose().

◆ damp

int32_t ada::idna::damp = 700
constexpr

Definition at line 7974 of file ada.cpp.

Referenced by adapt().

◆ decomposition_block

const uint16_t ada::idna::decomposition_block

Definition at line 3102 of file ada.cpp.

Referenced by compute_decomposition_length(), and decompose().

◆ decomposition_data

const char32_t ada::idna::decomposition_data

Definition at line 4746 of file ada.cpp.

Referenced by decompose().

◆ decomposition_index

const uint8_t ada::idna::decomposition_index

Definition at line 2870 of file ada.cpp.

Referenced by compute_decomposition_length(), and decompose().

◆ dir_table [1/2]

directions ada::idna::dir_table[]
static

Definition at line 8224 of file ada.cpp.

Referenced by find_direction().

◆ dir_table [2/2]

directions ada::idna::dir_table[]
static

Definition at line 8089 of file ada_idna.cpp.

◆ hangul_lbase

char32_t ada::idna::hangul_lbase = 0x1100
constexpr

Definition at line 7757 of file ada.cpp.

Referenced by compose(), and decompose().

◆ hangul_lcount

char32_t ada::idna::hangul_lcount = 19
constexpr

Definition at line 7758 of file ada.cpp.

Referenced by compose().

◆ hangul_ncount

char32_t ada::idna::hangul_ncount = hangul_vcount * hangul_tcount
constexpr

Definition at line 7761 of file ada.cpp.

Referenced by decompose().

◆ hangul_sbase

char32_t ada::idna::hangul_sbase = 0xAC00
constexpr

Definition at line 7754 of file ada.cpp.

Referenced by compose(), compute_decomposition_length(), and decompose().

◆ hangul_scount

char32_t ada::idna::hangul_scount
constexpr
Initial value:
=
constexpr char32_t hangul_tcount
Definition ada.cpp:7760
constexpr char32_t hangul_lcount
Definition ada.cpp:7758
constexpr char32_t hangul_vcount
Definition ada.cpp:7759

Definition at line 7762 of file ada.cpp.

Referenced by compose(), compute_decomposition_length(), and decompose().

◆ hangul_tbase

char32_t ada::idna::hangul_tbase = 0x11A7
constexpr

Definition at line 7755 of file ada.cpp.

Referenced by compose(), and decompose().

◆ hangul_tcount

char32_t ada::idna::hangul_tcount = 28
constexpr

Definition at line 7760 of file ada.cpp.

Referenced by compose(), compute_decomposition_length(), and decompose().

◆ hangul_vbase

char32_t ada::idna::hangul_vbase = 0x1161
constexpr

Definition at line 7756 of file ada.cpp.

Referenced by compose(), and decompose().

◆ hangul_vcount

char32_t ada::idna::hangul_vcount = 21
constexpr

Definition at line 7759 of file ada.cpp.

Referenced by compose().

◆ initial_bias

int32_t ada::idna::initial_bias = 72
constexpr

Definition at line 7975 of file ada.cpp.

Referenced by punycode_to_utf32(), utf32_to_punycode(), and verify_punycode().

◆ initial_n

uint32_t ada::idna::initial_n = 128
constexpr

Definition at line 7976 of file ada.cpp.

Referenced by punycode_to_utf32(), utf32_to_punycode(), and verify_punycode().

◆ is_forbidden_domain_code_point_table [1/2]

uint8_t ada::idna::is_forbidden_domain_code_point_table[]
staticconstexpr
Initial value:
= {
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}

Definition at line 9559 of file ada.cpp.

Referenced by is_forbidden_domain_code_point().

◆ is_forbidden_domain_code_point_table [2/2]

uint8_t ada::idna::is_forbidden_domain_code_point_table[]
staticconstexpr
Initial value:
= {
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}

Definition at line 9424 of file ada_idna.cpp.

◆ mappings

const uint32_t ada::idna::mappings

Definition at line 337 of file ada.cpp.

Referenced by map().

◆ skew

int32_t ada::idna::skew = 38
constexpr

Definition at line 7973 of file ada.cpp.

Referenced by adapt().

◆ table

const uint32_t ada::idna::table

Definition at line 719 of file ada.cpp.

Referenced by find_range_index(), and map().

◆ tmax

int32_t ada::idna::tmax = 26
constexpr

Definition at line 7972 of file ada.cpp.

Referenced by adapt(), punycode_to_utf32(), utf32_to_punycode(), and verify_punycode().

◆ tmin

int32_t ada::idna::tmin = 1
constexpr

Definition at line 7971 of file ada.cpp.

Referenced by adapt().