4 * (C) 2004 Joseph H. Allen
6 * This file is part of JOE (Joe's Own Editor)
12 __RCSID("$MirOS: contrib/code/jupp/utf8.h,v 1.5 2017/12/02 02:07:37 tg Exp $");
19 * c is unicode character.
20 * buf is 7 byte buffer- utf-8 coded character is written to this followed by a 0 termination.
21 * returns length (not including terminator).
24 int utf8_encode PARAMS((unsigned char *buf,int c));
26 /* UTF-8 decoder state machine */
29 unsigned char buf[8]; /* Record of sequence */
30 int ptr; /* Record pointer */
31 int state; /* Current state. 0 = idle, anything else is no. of chars left in sequence */
32 int accu; /* Character accumulator */
37 * Returns 0 - 7FFFFFFF: decoded character
38 * -1: character accepted, nothing decoded yet.
39 * -2: incomplete sequence
40 * -3: no sequence started, but character is between 128 - 191, 254 or 255
43 int utf8_decode PARAMS((struct utf8_sm *utf8_sm,unsigned char c));
45 int utf8_decode_string PARAMS((unsigned char *s));
47 int utf8_decode_fwrd PARAMS((unsigned char **p,int *plen));
49 /* Initialize state machine */
51 void utf8_init PARAMS((struct utf8_sm *utf8_sm));
54 void to_utf8 PARAMS((struct charmap *map,unsigned char *s,int c));
55 int from_utf8 PARAMS((struct charmap *map,unsigned char *s));
59 int mk_wcwidth PARAMS((int wide,int c));
61 extern struct charmap *locale_map; /* Default bytemap of terminal */
62 extern struct charmap *utf8_map; /* Bytemap for UTF-8 */