47 gdsp->
group =
nullptr;
78 for (n = 0; n < strlen(src); ++n)
79 if ((
unsigned char) src[n] > 127)
83 p = (
unsigned char *)
xmalloc(strlen(src) + c);
85 for (n = 0; n < strlen(src); ++n) {
87 s = (
unsigned char) src[n];
88 if (s > 127 && s < 192) {
102 return (
char *) dupp;
107char *hex_utf_char(
struct main_args *margs,
int flag);
124hex_utf_char(
struct main_args *margs,
int flag)
127 int iUTF2, iUTF3, iUTF4;
129 char *up = (flag ? margs->
ulist : margs->
tlist);
133 char *upd = strrchr(up,
'@');
134 size_t a = (upd ? (
size_t)(upd - up) : strlen(up) );
136 char *ul = (
char *)
xmalloc(strlen(up)+1);
143 while (n < strlen(up)) {
153 if (ival > 64 && ival < 71)
154 ichar = (ival - 55) * 16;
155 else if (ival > 96 && ival < 103)
156 ichar = (ival - 87) * 16;
157 else if (ival > 47 && ival < 58)
158 ichar = (ival - 48) * 16;
172 if (ival > 64 && ival < 71)
173 ichar = ichar + ival - 55;
174 else if (ival > 96 && ival < 103)
175 ichar = ichar + ival - 87;
176 else if (ival > 47 && ival < 58)
177 ichar = ichar + ival - 48;
185 if (iUTF2 == 0xC2 && ichar > 0x7F && ichar < 0xC0) {
187 ul[nl - 1] = (char)ichar;
188 }
else if (iUTF2 == 0xC3 && ichar > 0x7F && ichar < 0xC0) {
190 ul[nl - 1] = (char)(ichar + 64);
191 }
else if (iUTF2 > 0xC3 && iUTF2 < 0xE0 && ichar > 0x7F && ichar < 0xC0) {
193 ul[nl] = (char)ichar;
197 ul[nl] = (char)ichar;
199 debug((
char *)
"%s| %s: WARNING: Invalid UTF-8 sequence for Unicode %s\n",
LogTime(),
PROGRAM, ul);
204 if (iUTF3 == 0xE0 && ichar > 0x9F && ichar < 0xC0) {
206 ul[nl] = (char)ichar;
208 }
else if (iUTF3 > 0xE0 && iUTF3 < 0xED && ichar > 0x7F && ichar < 0xC0) {
210 ul[nl] = (char)ichar;
212 }
else if (iUTF3 == 0xED && ichar > 0x7F && ichar < 0xA0) {
214 ul[nl] = (char)ichar;
216 }
else if (iUTF3 > 0xED && iUTF3 < 0xF0 && ichar > 0x7F && ichar < 0xC0) {
218 ul[nl] = (char)ichar;
220 }
else if (iUTF3 > 0 && iUTF3 < 5 && ichar > 0x7F && ichar < 0xC0) {
222 ul[nl] = (char)ichar;
226 ul[nl] = (char)ichar;
228 debug((
char *)
"%s| %s: WARNING: Invalid UTF-8 sequence for Unicode %s\n",
LogTime(),
PROGRAM, ul);
233 if (iUTF4 == 0xF0 && ichar > 0x8F && ichar < 0xC0) {
235 ul[nl] = (char)ichar;
237 }
else if (iUTF4 > 0xF0 && iUTF3 < 0xF4 && ichar > 0x7F && ichar < 0xC0) {
239 ul[nl] = (char)ichar;
241 }
else if (iUTF4 == 0xF4 && ichar > 0x7F && ichar < 0x90) {
243 ul[nl] = (char)ichar;
245 }
else if (iUTF4 > 0 && iUTF4 < 5 && ichar > 0x7F && ichar < 0xC0) {
250 ul[nl] = (char)ichar;
254 ul[nl] = (char)ichar;
256 debug((
char *)
"%s| %s: WARNING: Invalid UTF-8 sequence for Unicode %s\n",
LogTime(),
PROGRAM, ul);
260 }
else if (ichar < 0x80) {
262 ul[nl] = (char)ichar;
264 }
else if (ichar > 0xC1 && ichar < 0xE0) {
267 ul[nl] = (char)ichar;
269 }
else if (ichar > 0xDF && ichar < 0xF0) {
272 ul[nl] = (char)ichar;
274 }
else if (ichar > 0xEF && ichar < 0xF5) {
277 ul[nl] = (char)ichar;
280 ul[nl] = (char)ichar;
282 debug((
char *)
"%s| %s: WARNING: Invalid UTF-8 sequence for Unicode %s\n",
LogTime(),
PROGRAM, ul);
290 if (iUTF2 || iUTF3 || iUTF4) {
291 debug((
char *)
"%s| %s: INFO: iUTF2: %d iUTF3: %d iUTF4: %d\n",
LogTime(),
PROGRAM, iUTF2, iUTF3, iUTF4);
292 debug((
char *)
"%s| %s: WARNING: Invalid UTF-8 sequence for Unicode %s\n",
LogTime(),
PROGRAM, ul);
297 ul = strcat(ul, upd);
306 struct gdstruct *gdsp =
nullptr, *gdspn =
nullptr;
326 char *hp1 = hex_utf_char(margs, 0);
327 char *hp2 = hex_utf_char(margs, 1);
328 char *up = utf8dup(margs);
333 char *gpbuf =
nullptr;
348 gpbuf = p = (
char *)
xmalloc(strlen(up) + strlen(hp1) + strlen(hp2) + 2);
355 gpbuf = p = (
char *)
xmalloc(strlen(hp1) + strlen(hp2) + 1);
362 gpbuf = p = (
char *)
xmalloc(strlen(up) + strlen(hp1) + 1);
372 gpbuf = p = (
char *)
xmalloc(strlen(up) + strlen(hp2) + 1);
391 if (*p ==
'\n' || *p ==
'\r') {
412 }
else if (*p ==
':') {
int create_gd(struct main_args *margs)
const char * LogTime(void)
void debug(const char *format,...)