benilla-re systems structs docs

Utf8ToUtf16Length

function · storm · primitive

Address
0x65b250 · 227 bytes, up to 0x65b332
Signature
int __stdcall (const char *src, uint32_t len, uint32_t *read)
Meaning
Counts the UTF-16 units of UTF-8 with the NUL, folding bytes signed so a four-byte form counts 1
Confidence
verified, proof one
Finding
storm/unicode#counting-utf-16-units
Test
storm::utf8_to_utf16_len_whole

Finding: Counting UTF-16 units in storm: UTF-8 to UTF-16

0x65b250(src, len, &read) counts, sequence by sequence and the NUL included, what the conversion would store, with the same table, the same bounds and the same results for a source that runs out, but folds each byte sign-extended. A lead from 0xc0 is then negative, so a sequence of two to four bytes (lead 0xc0 to 0xf7) folds above 0x10ffff, whatever follows the lead, and counts 1, a four-byte form included, which the conversion stores as two units; for valid UTF-8 the count is the code points plus one. read takes the bytes consumed, the NUL's included, and 0 for a null or empty source.

The derivation is in the doc.

Callers 4

Callees 0

None by a direct call or jump.

Calls and jumps by a bare address, from tables/calls.tsv.