Punycode/Punycode (IDNA)

Punycode is a Bootstring Encoding, using configuration and parameters for the Bootstring Algorithm described in RFC3492. Furthermore, there is an IDNA variant that prepends “xn–” to Unicode strings during encoding, and removes it during decoding (and otherwise does nothing). It uses custom states to manage the encodings.

Famously, Punycode is used for both Rust ABI identifier name mangling and in DNS for making Unicode names ASCII-only and clearly-marked as being derived from non-ASCII characters.

Transcoding Functions

cnc_mcerr cnc_mcnrtoc32n_punycode(size_t *__p_maybe_dst_len, ztd_char32_t **__p_maybe_dst, size_t *__p_src_len, const ztd_char_t **__p_src, cnc_pny_decode_state_t *__p_state)

See also

cnc_mcnrtoc32n

cnc_mcerr cnc_c32nrtomcn_punycode(size_t *__p_maybe_dst_len, ztd_char_t **__p_maybe_dst, size_t *__p_src_len, const ztd_char32_t **__p_src, cnc_pny_encode_state_t *__p_state)

See also

cnc_c32nrtomcn

cnc_mcerr cnc_mcsnrtoc32sn_punycode(size_t *__p_maybe_dst_len, ztd_char32_t **__p_maybe_dst, size_t *__p_src_len, const ztd_char_t **__p_src, cnc_pny_decode_state_t *__p_state)

See also

cnc_mcsnrtoc32sn

cnc_mcerr cnc_c32snrtomcsn_punycode(size_t *__p_maybe_dst_len, ztd_char_t **__p_maybe_dst, size_t *__p_src_len, const ztd_char32_t **__p_src, cnc_pny_encode_state_t *__p_state)

See also

cnc_c32snrtomcsn

State Type

struct cnc_pny_decode_state_t

A structure containing all of the necessary information for a general-purpose from-punycode transformation to UTF-32.

struct cnc_pny_encode_state_t

A structure containing all of the necessary information for a general-purpose to-punycode transformation from UTF-32.

State Functions

void cnc_pny_decode_state_set_input_incomplete(cnc_pny_decode_state_t *__state)

Tells the state that input should still be expected.

Parameters

__state[inout] The state to remove the expectation that input is complete from.

void cnc_pny_encode_state_set_input_incomplete(cnc_pny_encode_state_t *__state)

Tells the state that input should still be expected.

Parameters

__state[inout] The state to turn off its current completion state.

void cnc_pny_decode_state_set_input_complete(cnc_pny_decode_state_t *__state)

Returns whether or not the given cnc_pny_decode_state_t is expecting anymore input.

Parameters

__state[inout] The state to trigger the completion on.

void cnc_pny_encode_state_set_input_complete(cnc_pny_encode_state_t *__state)

Tells the state that input should still be expected.

Parameters

__state[inout] The state to remove the expectation that input is complete from.

bool cnc_pny_decode_state_is_input_complete(const cnc_pny_decode_state_t *__state)

Returns whether or not the given cnc_pny_decode_state_t is expecting anymore input.

Parameters

__state[inout] The state to to inspect.

bool cnc_pny_encode_state_is_input_complete(const cnc_pny_encode_state_t *__state)

Returns whether or not the given cnc_pny_encode_state_t is expecting anymore input.

Parameters

__state[inout] The state to inspect.

void cnc_pny_decode_state_set_assume_valid(cnc_pny_decode_state_t *__state, bool __value)

Returns whether or not the given cnc_pny_decode_state_t has no more data that needs to be output.

Parameters

__state[inout] The state to make operations assume the input is valid.

void cnc_pny_encode_state_set_assume_valid(cnc_pny_encode_state_t *__state, bool __value)

Returns whether or not the given cnc_pny_encode_state_t has no more data that needs to be output.

Parameters

__state[inout] The state to make operations assume the input is valid.

bool cnc_pny_decode_state_is_assuming_valid(const cnc_pny_decode_state_t *__state)

Returns whether or not the given cnc_pny_decode_state_t is assuming input data is valid.

Parameters

__state[inout] The state to inspect.

bool cnc_pny_encode_state_is_assuming_valid(const cnc_pny_encode_state_t *__state)

Returns whether or not the given cnc_pny_encode_state_t is assuming input data is valid.

Parameters

__state[inout] The state to inspect.