1
2
3
4
5
6
7
8
15
16
17
18
19
20
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
74
75
76
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
109
110
111
116
117
118
125
126
127
134
135
136
140
141
142
143
144
145
146
147
148
149
150
#ifndef UTF8_UTIL_H
#define UTF8_UTIL_H
#ifdef __cplusplus
extern "C" {
#endif
/* ... */
#include <jim-config.h>
#define MAX_UTF8_LEN 4
/* ... */
int utf8_fromunicode(char *p, unsigned uc);
#ifndef JIM_UTF8
#include <ctype.h>
#define utf8_strlen(S, B) ((B) < 0 ? (int)strlen(S) : (B))
#define utf8_strwidth(S, B) utf8_strlen((S), (B))
#define utf8_tounicode(S, CP) (*(CP) = (unsigned char)*(S), 1)
#define utf8_getchars(CP, C) (*(CP) = (C), 1)
#define utf8_upper(C) toupper(C)
#define utf8_title(C) toupper(C)
#define utf8_lower(C) tolower(C)
#define utf8_index(C, I) (I)
#define utf8_charlen(C) 1
#define utf8_prev_len(S, L) 1
#define utf8_width(C) 1
11 defines
/* ... */#else
#if !defined(JIM_BOOTSTRAP)
#define utf8_getchars utf8_fromunicode
/* ... */
int utf8_charlen(int c);
/* ... */
int utf8_strlen(const char *str, int bytelen);
/* ... */
int utf8_strwidth(const char *str, int charlen);
/* ... */
int utf8_index(const char *str, int charindex);
/* ... */
int utf8_tounicode(const char *str, int *uc);
/* ... */
int utf8_prev_len(const char *str, int len);
/* ... */
int utf8_upper(int uc);
/* ... */
int utf8_title(int uc);
/* ... */
int utf8_lower(int uc);
/* ... */
int utf8_width(int ch);
/* ... */
#endif
/* ... */
#endif
#ifdef __cplusplus
}extern "C" { ... }
#endif
/* ... */
#endif