4 * (C) 2004 Joseph H. Allen
6 * This file is part of JOE (Joe's Own Editor)
13 __RCSID("$MirOS: contrib/code/jupp/charmap.h,v 1.8 2017/12/02 04:32:39 tg Exp $");
16 /* For sorted from_map entries */
19 int first; /* Unicode */
26 struct charmap *next; /* Linked list of loaded character maps */
27 unsigned char *name; /* Name of this one */
29 int type; /* 0=byte, 1=UTF-8 */
31 /* Character predicate functions */
33 int (*is_punct)(struct charmap *map,int c);
34 int (*is_print)(struct charmap *map,int c);
35 int (*is_space)(struct charmap *map,int c);
36 int (*is_alpha_)(struct charmap *map,int c);
37 int (*is_alnum_)(struct charmap *map,int c);
39 /* Character conversion functions */
41 int (*to_lower)(struct charmap *map,int c);
42 int (*to_upper)(struct charmap *map,int c);
43 int (*to_uni)(struct charmap *map,int c);
44 int (*from_uni)(struct charmap *map,int c);
46 /* Information for byte-oriented character sets */
48 const int *to_map; /* Convert byte to unicode */
50 unsigned char lower_map[256]; /* Convert to lower case */
51 unsigned char upper_map[256];
53 struct pair from_map[256 + 2]; /* Convert from unicode to byte */
55 int from_size; /* No. pairs in from_map */
57 unsigned char print_map[32]; /* Bit map of printable characters */
58 unsigned char alpha__map[32]; /* Bit map of alphabetic characters and _ */
59 unsigned char alnum__map[32]; /* Bit map of alphanumeric characters and _ */
64 #define joe_ispunct(map,c) ((map)->is_punct((map),(c)))
65 #define joe_isprint(map,c) ((map)->is_print((map),(c)))
66 #define joe_isspace(map,c) ((map)->is_space((map),(c)))
67 #define joe_isalpha_(map,c) ((map)->is_alpha_((map),(c)))
68 #define joe_isalnum_(map,c) ((map)->is_alnum_((map),(c)))
69 int joe_isblank PARAMS((struct charmap *map,int c));
70 int joe_isspace_eof PARAMS((struct charmap *map,int c));
72 /* Conversion functions */
74 #define joe_tolower(map,c) ((map)->to_lower((map),(c)))
75 #define joe_toupper(map,c) ((map)->to_upper((map),(c)))
76 #define joe_to_uni(map,c) ((map)->to_uni((map),(c)))
77 #define joe_from_uni(map,c) ((map)->from_uni((map),(c)))
78 unsigned char *joe_strtolower PARAMS((unsigned char *s));
80 /* Find (load if necessary) a character set */
81 struct charmap *find_charmap PARAMS((const unsigned char *name));
83 /* Get available encodings */
84 unsigned char **get_encodings PARAMS((void));
86 int to_uni PARAMS((struct charmap *cset, int c));
87 int from_uni PARAMS((struct charmap *cset, int c));