1 /* $MirOS: contrib/code/jupp/charmap.h,v 1.5 2014/06/26 17:51:14 tg Exp $ */
5 * (C) 2004 Joseph H. Allen
7 * This file is part of JOE (Joe's Own Editor)
17 /* For sorted from_map entries */
20 int first; /* Unicode */
27 struct charmap *next; /* Linked list of loaded character maps */
28 unsigned char *name; /* Name of this one */
30 int type; /* 0=byte, 1=UTF-8 */
32 /* Character predicate functions */
34 int (*is_punct)(struct charmap *map,int c);
35 int (*is_print)(struct charmap *map,int c);
36 int (*is_space)(struct charmap *map,int c);
37 int (*is_alpha_)(struct charmap *map,int c);
38 int (*is_alnum_)(struct charmap *map,int c);
40 /* Character conversion functions */
42 int (*to_lower)(struct charmap *map,int c);
43 int (*to_upper)(struct charmap *map,int c);
44 int (*to_uni)(struct charmap *map,int c);
45 int (*from_uni)(struct charmap *map,int c);
47 /* Information for byte-oriented character sets */
49 const int *to_map; /* Convert byte to unicode */
51 unsigned char lower_map[256]; /* Convert to lower case */
52 unsigned char upper_map[256];
54 struct pair from_map[256 + 2]; /* Convert from unicode to byte */
56 int from_size; /* No. paris in from_map */
58 unsigned char print_map[32]; /* Bit map of printable characters */
59 unsigned char alpha__map[32]; /* Bit map of alphabetic characters and _ */
60 unsigned char alnum__map[32]; /* Bit map of alphanumeric characters and _ */
65 #define joe_ispunct(map,c) ((map)->is_punct((map),(c)))
66 #define joe_isprint(map,c) ((map)->is_print((map),(c)))
67 #define joe_isspace(map,c) ((map)->is_space((map),(c)))
68 #define joe_isalpha_(map,c) ((map)->is_alpha_((map),(c)))
69 #define joe_isalnum_(map,c) ((map)->is_alnum_((map),(c)))
70 int joe_isblank PARAMS((struct charmap *map,int c));
71 int joe_isspace_eof PARAMS((struct charmap *map,int c));
73 /* Conversion functions */
75 #define joe_tolower(map,c) ((map)->to_lower((map),(c)))
76 #define joe_toupper(map,c) ((map)->to_upper((map),(c)))
77 #define joe_to_uni(map,c) ((map)->to_uni((map),(c)))
78 #define joe_from_uni(map,c) ((map)->from_uni((map),(c)))
79 unsigned char *joe_strtolower PARAMS((unsigned char *s));
81 /* Find (load if necessary) a character set */
82 struct charmap *find_charmap PARAMS((const unsigned char *name));
84 /* Get available encodings */
85 unsigned char **get_encodings PARAMS((void));
87 int to_uni PARAMS((struct charmap *cset, int c));
88 int from_uni PARAMS((struct charmap *cset, int c));