Skip to content

niso_intl.h: Intl for engines without it

Generated from crates/niso-intl/include/niso_intl.h when the site was built at 7aa23e2.

From crates/niso-intl/include/niso_intl.h, a header of its own outside niso_runtime.h.

Functions: niso_intl_call, niso_intl_free, niso_intl_load_data

niso-intl: ECMA-402’s locale data and formatting, for a binding whose engine has no Intl. One entry point takes an operation name and string arguments and returns strings; js/intl.js is its only caller.

typedef struct niso_intl_str {
const char* ptr;
size_t len;
} niso_intl_str;

What niso_intl_call returns: count results, each lens[i] bytes, one after another in data. Freed with niso_intl_free.

typedef struct niso_intl_result {
char* data;
size_t* lens;
size_t count;
} niso_intl_result;

Runs operation op on args. 0: out holds strings; 1 (RangeError) or 2 (TypeError): out holds the error’s message; 3: niso-intl failed (a panic) and out holds why; 4: out holds bytes, for segment: each segment’s UTF-16 end as a native-endian uint32_t, its top bit set for a word-like word.

int32_t niso_intl_call(const char* op, size_t op_len, const niso_intl_str* args, size_t argc, niso_intl_result* out);
void niso_intl_free(niso_intl_result result);

Adds len bytes at data, a postcard blob such as data/names.postcard, to the locale data later calls use: it answers the data markers and locales it has ahead of earlier loads and the build’s. 0 if it loaded, 1 if it is not a blob, 2 in a full build, which has all the data already. Load only blobs from a trusted source, like the app’s own assets: ICU4X trusts its data.

int32_t niso_intl_load_data(const uint8_t* data, size_t len);