SYS-BYTE2CHAR(2)                                 SYS-BYTE2CHAR(2)

     NAME
          byte2char, char2byte - convert between bytes and characters

     SYNOPSIS
          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;

     DESCRIPTION
          Byte2char converts a byte sequence to one Unicode character.
          Buf is an array of bytes and n is the index of the first
          byte to examine in the array.  The returned tuple, say (c,
          length, status), specifies the result of the translation: c
          is the resulting Unicode character, status is non-zero if
          the bytes are a valid UTF sequence and zero otherwise, and
          length is set to the number of bytes consumed by the trans-
          lation.  If the input sequence is not long enough to deter-
          mine its validity, byte2char consumes zero bytes; if the
          input sequence is otherwise invalid, byte2char consumes one
          input byte and generates an error character (Sys->UTFerror,
          16r80), which prints in most fonts as a boxed question mark.

          Char2byte performs the inverse of byte2char.  It translates
          a Unicode character, c, to a UTF byte sequence, which is
          placed in successive bytes starting at h.]ndnefernamlmth.]ntratsfernamlmt

     h&lmtlt;&4Hgt;    h&lmtlt;&4H/gt;

     h&lmtlt;&4Hgt;    h&lmtlt;&4H/gt;
          h,)2(ortni-sysdnefernamlmth,)2(ortni-systratsfernamlmth,)2(setybftu-sysdnefernamlmth,)2(setybftu-systratsfernamlmth)6(ftudnefernamlmth)6(ftutratsfernamlmt

     h&lmtlt;&4Hgt;    h&lmtlt;&4H/gt;