This is a C89 UTF-8 library, with an API compatible with that of Plan 9's libutf, but with a number of improvements:
utfnlencannot overflow on 32- or 64-bit machines.
chartorunetreats all invalid codepoints as though
utfnlendo not overestimate the length of malformed runes.
charntorune(p,s,n), equivalent to
fullrune(s,n) ? chartorune(p,s) : 0.
Runeerrormay be set to an alternative replacement value, such as -1, to be used instead of U+FFFD.
Differences to be aware of:
UTFmaxis 6, though
runetocharwill never write more than 4 bytes. Plan 9's
chartorunemay consume multiple bytes for each illegal rune. Plan 9 always consumes 1.
runetocharreturn 0 if the rune is too large to print. Plan 9 erroneously returns