include "sys.m"; sys:= load Sys Sys->PATH; byte2char: fn(buf: array of byte, n: int): (int, int, int); char2byte: fn(c: int, buf: array of byte, n: int): int;
c
|
The resulting Unicode character.
|
len
|
The number of bytes consumed by the translation.
|
status
|
Non-zero if the bytes are a valid UTF sequence and zero otherwise.
|
If the input sequence is not long enough to determine its validity, byte2char consumes zero bytes. If the input sequence is otherwise invalid, byte2char consumes one input byte and generates an error character (16r80, Sys->UTFerror), which prints (in most fonts) as a boxed question mark.
char2byte (c, buf, n)
The char2byte performs the inverse of byte2char. It translates a Unicode character, c, to a UTF byte sequence. The results are placed in buf, which should have at least n bytes available. The longest UTF sequence for a single Unicode character is Sys->UTFmax (3) bytes. See Also
Limbo System Modules, utfbytes, and utf
Notes
If the array bounds are invalid or insufficient to hold results, a run-time error occurs.