cnc_mcstate_t

The state object is used during conversions to provide a place for the function to write any temporary data into. This is useful for encodings such as IBM or Microsoft’s rendition of SHIFT-JIS, where specific shift sequences are used to provide additional sequences or information for a given input or output string.

Note

For the c8, c16, and c32 prefixed/suffixed functions, it may not use the state objects to store “partial writes” or “partial reads” of the data. Any encoding defined as UTF-8, UTF-16, and UTF-32 used through the mc (execution encoding-related) or mwc (wide execution encoding-related) shall also not be used to store partial pieces of the input or partial pieces of the output in order to accumulate information before reading in more data or writing out. If there is insufficient space to do a write to the output, cnc_mcerr_insufficient_output must be returned. Similarly, if there is insufficient data and the data is at the very end, then cnc_mcerr_incomplete_input must be returned.

An implementation may define encodings which are not UTF-8, UTF-16, or UTF-32 that does perform partial writes, such as a "UTF-8-partial" or "UTF-32-partial". But it shall not have the same LC_TYPE identifier as the UTF-8, UTF-16, or UTF-32 encodings.

union cnc_mcstate_t
#include <mcstate.h>

The state for the typed conversion functions.

Remark

This is a complete object, but none of its members should be accessed or relied upon in any way, shape or form. If you do so, it is Undefined Behavior.

Public Members

struct cnc_mcstate_t::cnc_header_t header
struct cnc_mcstate_t::__raw_t raw
struct __raw_t
#include <mcstate.h>

The raw type for user use.

Public Members

cnc_mcstate_indicator indicator

The indactor. Must be set by any custom encoding routine using cnc_mcstate_t and desiring custom completion behavior to CNC_MCSTATE_INDICATOR_RAW.

unsigned int assume_valid

Universal “assume valid input” flag for use with “-unchecked”-suffixed encodings.

unsigned int __paddding

Padding to keep consistent sizing. Not meant to be part of any location. Do not access.

state_is_complete_function *completion_function

The completion function. If behavior beyond a check for the provided fixed-size data is zero is desired, then this must be set to a valid function pointer. Otherwise, it must be a null pointer.

unsigned char raw_data[(sizeof(void*) * 3)]

Leftover data blob for use by the user. The user is responsible for its management within the conversion functions.

struct cnc_header_t
#include <mcstate.h>

Shared data as part of every structure within a cnc_mcstate_t.

Public Members

cnc_mcstate_indicator indicator

The indactor. Must be set by any custom encoding routine using cnc_mcstate_t and desiring custom completion behavior to CNC_MCSTATE_INDICATOR_RAW.

unsigned int __assume_valid

Universal “assume valid input” flag for use with “-unchecked”-suffixed encodings. Do not access.

unsigned int __paddding

Padding to keep consistent sizing. Not meant to be part of any location. Do not access.

bool cnc_mcstate_is_complete(const cnc_mcstate_t *__state)

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

Parameters

__state[in] The state object to check is complete/finished and has no pending writes to do or data to gather.

State Functions

void cnc_mcstate_set_assume_valid(cnc_mcstate_t *__state, bool __check_validity)

Sets internal state for the cnc_mcstate_t object which will set its assume valid bits, if applicable.

Parameters
  • __state[inout] The state to turn validity on for.

  • __check_validity[inout] Whether or not to check for validity.

bool cnc_mcstate_is_assuming_valid(const cnc_mcstate_t *__state)

Gets the internal state for the cnc_mcstate_t

object representing its current “assume

valid” state.

Parameters

__state[inout] The state to return validity on for.