Skip to content

Latest commit

 

History

History
550 lines (454 loc) · 16.2 KB

physfs_unicode.c

File metadata and controls

550 lines (454 loc) · 16.2 KB
 
Nov 5, 2006
Nov 5, 2006
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#define __PHYSICSFS_INTERNAL__
#include "physfs_internal.h"
/*
* From rfc3629, the UTF-8 spec:
* http://www.ietf.org/rfc/rfc3629.txt
*
* Char. number range | UTF-8 octet sequence
* (hexadecimal) | (binary)
* --------------------+---------------------------------------------
* 0000 0000-0000 007F | 0xxxxxxx
* 0000 0080-0000 07FF | 110xxxxx 10xxxxxx
* 0000 0800-0000 FFFF | 1110xxxx 10xxxxxx 10xxxxxx
* 0001 0000-0010 FFFF | 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
*/
/*
* This may not be the best value, but it's one that isn't represented
* in Unicode (0x10FFFF is the largest codepoint value). We return this
* value from utf8codepoint() if there's bogus bits in the
* stream. utf8codepoint() will turn this value into something
* reasonable (like a question mark), for text that wants to try to recover,
* whereas utf8valid() will use the value to determine if a string has bad
* bits.
*/
#define UNICODE_BOGUS_CHAR_VALUE 0xFFFFFFFF
/*
* This is the codepoint we currently return when there was bogus bits in a
* UTF-8 string. May not fly in Asian locales?
*/
#define UNICODE_BOGUS_CHAR_CODEPOINT '?'
static PHYSFS_uint32 utf8codepoint(const char **_str)
{
const char *str = *_str;
PHYSFS_uint32 retval = 0;
PHYSFS_uint32 octet = (PHYSFS_uint32) ((PHYSFS_uint8) *str);
PHYSFS_uint32 octet2, octet3, octet4;
if (octet == 0) /* null terminator, end of string. */
return 0;
else if (octet < 128) /* one octet char: 0 to 127 */
{
(*_str)++; /* skip to next possible start of codepoint. */
Jan 28, 2010
Jan 28, 2010
49
return octet;
Nov 5, 2006
Nov 5, 2006
50
51
52
53
54
55
56
57
58
59
60
61
62
63
} /* else if */
else if ((octet > 127) && (octet < 192)) /* bad (starts with 10xxxxxx). */
{
/*
* Apparently each of these is supposed to be flagged as a bogus
* char, instead of just resyncing to the next valid codepoint.
*/
(*_str)++; /* skip to next possible start of codepoint. */
return UNICODE_BOGUS_CHAR_VALUE;
} /* else if */
else if (octet < 224) /* two octets */
{
Jun 1, 2011
Jun 1, 2011
64
(*_str)++; /* advance at least one byte in case of an error */
Nov 5, 2006
Nov 5, 2006
65
66
67
68
69
octet -= (128+64);
octet2 = (PHYSFS_uint32) ((PHYSFS_uint8) *(++str));
if ((octet2 & (128+64)) != 128) /* Format isn't 10xxxxxx? */
return UNICODE_BOGUS_CHAR_VALUE;
Jun 1, 2011
Jun 1, 2011
70
*_str += 1; /* skip to next possible start of codepoint. */
Nov 5, 2006
Nov 5, 2006
71
72
73
74
75
76
77
retval = ((octet << 6) | (octet2 - 128));
if ((retval >= 0x80) && (retval <= 0x7FF))
return retval;
} /* else if */
else if (octet < 240) /* three octets */
{
Jun 1, 2011
Jun 1, 2011
78
(*_str)++; /* advance at least one byte in case of an error */
Nov 5, 2006
Nov 5, 2006
79
80
81
82
83
84
85
86
87
octet -= (128+64+32);
octet2 = (PHYSFS_uint32) ((PHYSFS_uint8) *(++str));
if ((octet2 & (128+64)) != 128) /* Format isn't 10xxxxxx? */
return UNICODE_BOGUS_CHAR_VALUE;
octet3 = (PHYSFS_uint32) ((PHYSFS_uint8) *(++str));
if ((octet3 & (128+64)) != 128) /* Format isn't 10xxxxxx? */
return UNICODE_BOGUS_CHAR_VALUE;
Jun 1, 2011
Jun 1, 2011
88
*_str += 2; /* skip to next possible start of codepoint. */
Nov 5, 2006
Nov 5, 2006
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
retval = ( ((octet << 12)) | ((octet2-128) << 6) | ((octet3-128)) );
/* There are seven "UTF-16 surrogates" that are illegal in UTF-8. */
switch (retval)
{
case 0xD800:
case 0xDB7F:
case 0xDB80:
case 0xDBFF:
case 0xDC00:
case 0xDF80:
case 0xDFFF:
return UNICODE_BOGUS_CHAR_VALUE;
} /* switch */
/* 0xFFFE and 0xFFFF are illegal, too, so we check them at the edge. */
if ((retval >= 0x800) && (retval <= 0xFFFD))
return retval;
} /* else if */
else if (octet < 248) /* four octets */
{
Jun 1, 2011
Jun 1, 2011
111
(*_str)++; /* advance at least one byte in case of an error */
Nov 5, 2006
Nov 5, 2006
112
113
114
115
116
117
118
119
120
121
122
123
124
octet -= (128+64+32+16);
octet2 = (PHYSFS_uint32) ((PHYSFS_uint8) *(++str));
if ((octet2 & (128+64)) != 128) /* Format isn't 10xxxxxx? */
return UNICODE_BOGUS_CHAR_VALUE;
octet3 = (PHYSFS_uint32) ((PHYSFS_uint8) *(++str));
if ((octet3 & (128+64)) != 128) /* Format isn't 10xxxxxx? */
return UNICODE_BOGUS_CHAR_VALUE;
octet4 = (PHYSFS_uint32) ((PHYSFS_uint8) *(++str));
if ((octet4 & (128+64)) != 128) /* Format isn't 10xxxxxx? */
return UNICODE_BOGUS_CHAR_VALUE;
Jun 1, 2011
Jun 1, 2011
125
*_str += 3; /* skip to next possible start of codepoint. */
Nov 5, 2006
Nov 5, 2006
126
127
128
129
130
131
132
133
134
135
136
137
138
139
retval = ( ((octet << 18)) | ((octet2 - 128) << 12) |
((octet3 - 128) << 6) | ((octet4 - 128)) );
if ((retval >= 0x10000) && (retval <= 0x10FFFF))
return retval;
} /* else if */
/*
* Five and six octet sequences became illegal in rfc3629.
* We throw the codepoint away, but parse them to make sure we move
* ahead the right number of bytes and don't overflow the buffer.
*/
else if (octet < 252) /* five octets */
{
Jun 1, 2011
Jun 1, 2011
140
(*_str)++; /* advance at least one byte in case of an error */
Nov 5, 2006
Nov 5, 2006
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
octet = (PHYSFS_uint32) ((PHYSFS_uint8) *(++str));
if ((octet & (128+64)) != 128) /* Format isn't 10xxxxxx? */
return UNICODE_BOGUS_CHAR_VALUE;
octet = (PHYSFS_uint32) ((PHYSFS_uint8) *(++str));
if ((octet & (128+64)) != 128) /* Format isn't 10xxxxxx? */
return UNICODE_BOGUS_CHAR_VALUE;
octet = (PHYSFS_uint32) ((PHYSFS_uint8) *(++str));
if ((octet & (128+64)) != 128) /* Format isn't 10xxxxxx? */
return UNICODE_BOGUS_CHAR_VALUE;
octet = (PHYSFS_uint32) ((PHYSFS_uint8) *(++str));
if ((octet & (128+64)) != 128) /* Format isn't 10xxxxxx? */
return UNICODE_BOGUS_CHAR_VALUE;
Jun 1, 2011
Jun 1, 2011
157
*_str += 4; /* skip to next possible start of codepoint. */
Nov 5, 2006
Nov 5, 2006
158
159
160
161
162
return UNICODE_BOGUS_CHAR_VALUE;
} /* else if */
else /* six octets */
{
Jun 1, 2011
Jun 1, 2011
163
(*_str)++; /* advance at least one byte in case of an error */
Nov 5, 2006
Nov 5, 2006
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
octet = (PHYSFS_uint32) ((PHYSFS_uint8) *(++str));
if ((octet & (128+64)) != 128) /* Format isn't 10xxxxxx? */
return UNICODE_BOGUS_CHAR_VALUE;
octet = (PHYSFS_uint32) ((PHYSFS_uint8) *(++str));
if ((octet & (128+64)) != 128) /* Format isn't 10xxxxxx? */
return UNICODE_BOGUS_CHAR_VALUE;
octet = (PHYSFS_uint32) ((PHYSFS_uint8) *(++str));
if ((octet & (128+64)) != 128) /* Format isn't 10xxxxxx? */
return UNICODE_BOGUS_CHAR_VALUE;
octet = (PHYSFS_uint32) ((PHYSFS_uint8) *(++str));
if ((octet & (128+64)) != 128) /* Format isn't 10xxxxxx? */
return UNICODE_BOGUS_CHAR_VALUE;
octet = (PHYSFS_uint32) ((PHYSFS_uint8) *(++str));
if ((octet & (128+64)) != 128) /* Format isn't 10xxxxxx? */
return UNICODE_BOGUS_CHAR_VALUE;
*_str += 6; /* skip to next possible start of codepoint. */
return UNICODE_BOGUS_CHAR_VALUE;
} /* else if */
return UNICODE_BOGUS_CHAR_VALUE;
} /* utf8codepoint */
Mar 15, 2007
Mar 15, 2007
191
192
void PHYSFS_utf8ToUcs4(const char *src, PHYSFS_uint32 *dst, PHYSFS_uint64 len)
Nov 5, 2006
Nov 5, 2006
193
194
195
196
197
198
199
200
201
202
203
204
205
206
{
len -= sizeof (PHYSFS_uint32); /* save room for null char. */
while (len >= sizeof (PHYSFS_uint32))
{
PHYSFS_uint32 cp = utf8codepoint(&src);
if (cp == 0)
break;
else if (cp == UNICODE_BOGUS_CHAR_VALUE)
cp = UNICODE_BOGUS_CHAR_CODEPOINT;
*(dst++) = cp;
len -= sizeof (PHYSFS_uint32);
} /* while */
*dst = 0;
Mar 15, 2007
Mar 15, 2007
207
208
} /* PHYSFS_utf8ToUcs4 */
Nov 5, 2006
Nov 5, 2006
209
Mar 15, 2007
Mar 15, 2007
210
void PHYSFS_utf8ToUcs2(const char *src, PHYSFS_uint16 *dst, PHYSFS_uint64 len)
Nov 5, 2006
Nov 5, 2006
211
212
213
214
215
216
217
218
219
220
{
len -= sizeof (PHYSFS_uint16); /* save room for null char. */
while (len >= sizeof (PHYSFS_uint16))
{
PHYSFS_uint32 cp = utf8codepoint(&src);
if (cp == 0)
break;
else if (cp == UNICODE_BOGUS_CHAR_VALUE)
cp = UNICODE_BOGUS_CHAR_CODEPOINT;
Aug 20, 2010
Aug 20, 2010
221
if (cp > 0xFFFF) /* UTF-16 surrogates (bogus chars in UCS-2) */
Nov 5, 2006
Nov 5, 2006
222
223
224
225
226
227
228
cp = UNICODE_BOGUS_CHAR_CODEPOINT;
*(dst++) = cp;
len -= sizeof (PHYSFS_uint16);
} /* while */
*dst = 0;
Mar 15, 2007
Mar 15, 2007
229
} /* PHYSFS_utf8ToUcs2 */
Nov 5, 2006
Nov 5, 2006
230
Aug 20, 2010
Aug 20, 2010
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
void PHYSFS_utf8ToUtf16(const char *src, PHYSFS_uint16 *dst, PHYSFS_uint64 len)
{
len -= sizeof (PHYSFS_uint16); /* save room for null char. */
while (len >= sizeof (PHYSFS_uint16))
{
PHYSFS_uint32 cp = utf8codepoint(&src);
if (cp == 0)
break;
else if (cp == UNICODE_BOGUS_CHAR_VALUE)
cp = UNICODE_BOGUS_CHAR_CODEPOINT;
if (cp > 0xFFFF) /* encode as surrogate pair */
{
if (len < (sizeof (PHYSFS_uint16) * 2))
break; /* not enough room for the pair, stop now. */
cp -= 0x10000; /* Make this a 20-bit value */
*(dst++) = 0xD800 + ((cp >> 10) & 0x3FF);
len -= sizeof (PHYSFS_uint16);
cp = 0xDC00 + (cp & 0x3FF);
} /* if */
*(dst++) = cp;
len -= sizeof (PHYSFS_uint16);
} /* while */
*dst = 0;
} /* PHYSFS_utf8ToUtf16 */
Nov 5, 2006
Nov 5, 2006
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
static void utf8fromcodepoint(PHYSFS_uint32 cp, char **_dst, PHYSFS_uint64 *_len)
{
char *dst = *_dst;
PHYSFS_uint64 len = *_len;
if (len == 0)
return;
if (cp > 0x10FFFF)
cp = UNICODE_BOGUS_CHAR_CODEPOINT;
else if ((cp == 0xFFFE) || (cp == 0xFFFF)) /* illegal values. */
cp = UNICODE_BOGUS_CHAR_CODEPOINT;
else
{
/* There are seven "UTF-16 surrogates" that are illegal in UTF-8. */
switch (cp)
{
case 0xD800:
case 0xDB7F:
case 0xDB80:
case 0xDBFF:
case 0xDC00:
case 0xDF80:
case 0xDFFF:
cp = UNICODE_BOGUS_CHAR_CODEPOINT;
} /* switch */
} /* else */
/* Do the encoding... */
if (cp < 0x80)
{
*(dst++) = (char) cp;
len--;
} /* if */
else if (cp < 0x800)
{
if (len < 2)
len = 0;
else
{
*(dst++) = (char) ((cp >> 6) | 128 | 64);
*(dst++) = (char) (cp & 0x3F) | 128;
len -= 2;
} /* else */
} /* else if */
else if (cp < 0x10000)
{
if (len < 3)
len = 0;
else
{
*(dst++) = (char) ((cp >> 12) | 128 | 64 | 32);
*(dst++) = (char) ((cp >> 6) & 0x3F) | 128;
*(dst++) = (char) (cp & 0x3F) | 128;
len -= 3;
} /* else */
} /* else if */
else
{
if (len < 4)
len = 0;
else
{
*(dst++) = (char) ((cp >> 18) | 128 | 64 | 32 | 16);
*(dst++) = (char) ((cp >> 12) & 0x3F) | 128;
*(dst++) = (char) ((cp >> 6) & 0x3F) | 128;
*(dst++) = (char) (cp & 0x3F) | 128;
len -= 4;
} /* else if */
} /* else */
*_dst = dst;
*_len = len;
} /* utf8fromcodepoint */
#define UTF8FROMTYPE(typ, src, dst, len) \
Aug 20, 2010
Aug 20, 2010
342
if (len == 0) return; \
Nov 5, 2006
Nov 5, 2006
343
344
345
len--; \
while (len) \
{ \
Jun 3, 2009
Jun 3, 2009
346
const PHYSFS_uint32 cp = (PHYSFS_uint32) ((typ) (*(src++))); \
Nov 5, 2006
Nov 5, 2006
347
348
349
350
351
if (cp == 0) break; \
utf8fromcodepoint(cp, &dst, &len); \
} \
*dst = '\0'; \
Mar 15, 2007
Mar 15, 2007
352
void PHYSFS_utf8FromUcs4(const PHYSFS_uint32 *src, char *dst, PHYSFS_uint64 len)
Nov 5, 2006
Nov 5, 2006
353
354
{
UTF8FROMTYPE(PHYSFS_uint32, src, dst, len);
Mar 15, 2007
Mar 15, 2007
355
} /* PHYSFS_utf8FromUcs4 */
Nov 5, 2006
Nov 5, 2006
356
Mar 15, 2007
Mar 15, 2007
357
void PHYSFS_utf8FromUcs2(const PHYSFS_uint16 *src, char *dst, PHYSFS_uint64 len)
Nov 5, 2006
Nov 5, 2006
358
359
{
UTF8FROMTYPE(PHYSFS_uint64, src, dst, len);
Aug 20, 2010
Aug 20, 2010
360
} /* PHYSFS_utf8FromUcs2 */
Nov 5, 2006
Nov 5, 2006
361
362
/* latin1 maps to unicode codepoints directly, we just utf-8 encode it. */
Mar 15, 2007
Mar 15, 2007
363
void PHYSFS_utf8FromLatin1(const char *src, char *dst, PHYSFS_uint64 len)
Nov 5, 2006
Nov 5, 2006
364
365
{
UTF8FROMTYPE(PHYSFS_uint8, src, dst, len);
Mar 15, 2007
Mar 15, 2007
366
} /* PHYSFS_utf8FromLatin1 */
Nov 5, 2006
Nov 5, 2006
367
368
369
#undef UTF8FROMTYPE
Mar 15, 2007
Mar 15, 2007
370
Aug 20, 2010
Aug 20, 2010
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
void PHYSFS_utf8FromUtf16(const PHYSFS_uint16 *src, char *dst, PHYSFS_uint64 len)
{
if (len == 0)
return;
len--;
while (len)
{
PHYSFS_uint32 cp = (PHYSFS_uint32) *(src++);
if (cp == 0)
break;
/* Orphaned second half of surrogate pair? */
if ((cp >= 0xDC00) && (cp <= 0xDFFF))
cp = UNICODE_BOGUS_CHAR_CODEPOINT;
else if ((cp >= 0xD800) && (cp <= 0xDBFF)) /* start surrogate pair! */
{
const PHYSFS_uint32 pair = (PHYSFS_uint32) *src;
if ((pair < 0xDC00) || (pair > 0xDFFF))
cp = UNICODE_BOGUS_CHAR_CODEPOINT;
else
{
Aug 24, 2010
Aug 24, 2010
393
src++; /* eat the other surrogate. */
Aug 20, 2010
Aug 20, 2010
394
395
396
397
398
399
400
401
402
403
404
cp = (((cp - 0xD800) << 10) | (pair - 0xDC00));
} /* else */
} /* else if */
utf8fromcodepoint(cp, &dst, &len);
} /* while */
*dst = '\0';
} /* PHYSFS_utf8FromUtf16 */
Mar 15, 2007
Mar 15, 2007
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
typedef struct CaseFoldMapping
{
PHYSFS_uint32 from;
PHYSFS_uint32 to0;
PHYSFS_uint32 to1;
PHYSFS_uint32 to2;
} CaseFoldMapping;
typedef struct CaseFoldHashBucket
{
const PHYSFS_uint8 count;
const CaseFoldMapping *list;
} CaseFoldHashBucket;
#include "physfs_casefolding.h"
static void locate_case_fold_mapping(const PHYSFS_uint32 from,
PHYSFS_uint32 *to)
{
PHYSFS_uint32 i;
const PHYSFS_uint8 hashed = ((from ^ (from >> 8)) & 0xFF);
const CaseFoldHashBucket *bucket = &case_fold_hash[hashed];
const CaseFoldMapping *mapping = bucket->list;
for (i = 0; i < bucket->count; i++, mapping++)
{
if (mapping->from == from)
{
to[0] = mapping->to0;
to[1] = mapping->to1;
to[2] = mapping->to2;
return;
} /* if */
} /* for */
/* Not found...there's no remapping for this codepoint. */
to[0] = from;
to[1] = 0;
to[2] = 0;
} /* locate_case_fold_mapping */
static int utf8codepointcmp(const PHYSFS_uint32 cp1, const PHYSFS_uint32 cp2)
{
PHYSFS_uint32 folded1[3], folded2[3];
Aug 15, 2014
Aug 15, 2014
450
451
452
453
if (cp1 == cp2)
return 0; /* obviously matches. */
Mar 15, 2007
Mar 15, 2007
454
455
locate_case_fold_mapping(cp1, folded1);
locate_case_fold_mapping(cp2, folded2);
Nov 28, 2012
Nov 28, 2012
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
if (folded1[0] < folded2[0])
return -1;
else if (folded1[0] > folded2[0])
return 1;
else if (folded1[1] < folded2[1])
return -1;
else if (folded1[1] > folded2[1])
return 1;
else if (folded1[2] < folded2[2])
return -1;
else if (folded1[2] > folded2[2])
return 1;
return 0; /* complete match. */
Mar 15, 2007
Mar 15, 2007
471
472
473
} /* utf8codepointcmp */
Mar 22, 2012
Mar 22, 2012
474
int __PHYSFS_utf8stricmp(const char *str1, const char *str2)
Mar 15, 2007
Mar 15, 2007
475
476
477
478
479
{
while (1)
{
const PHYSFS_uint32 cp1 = utf8codepoint(&str1);
const PHYSFS_uint32 cp2 = utf8codepoint(&str2);
Nov 28, 2012
Nov 28, 2012
480
481
482
483
484
const int rc = utf8codepointcmp(cp1, cp2);
if (rc != 0)
return rc;
else if (cp1 == 0)
break; /* complete match. */
Mar 15, 2007
Mar 15, 2007
485
486
} /* while */
Apr 13, 2009
Apr 13, 2009
487
return 0;
Mar 22, 2012
Mar 22, 2012
488
} /* __PHYSFS_utf8stricmp */
Mar 15, 2007
Mar 15, 2007
489
490
491
492
493
494
495
496
int __PHYSFS_utf8strnicmp(const char *str1, const char *str2, PHYSFS_uint32 n)
{
while (n > 0)
{
const PHYSFS_uint32 cp1 = utf8codepoint(&str1);
const PHYSFS_uint32 cp2 = utf8codepoint(&str2);
Nov 28, 2012
Nov 28, 2012
497
498
499
500
501
const int rc = utf8codepointcmp(cp1, cp2);
if (rc != 0)
return rc;
else if (cp1 == 0)
return 0;
Mar 15, 2007
Mar 15, 2007
502
503
504
n--;
} /* while */
Nov 28, 2012
Nov 28, 2012
505
return 0; /* matched to n chars. */
Mar 15, 2007
Mar 15, 2007
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
} /* __PHYSFS_utf8strnicmp */
int __PHYSFS_stricmpASCII(const char *str1, const char *str2)
{
while (1)
{
const char ch1 = *(str1++);
const char ch2 = *(str2++);
const char cp1 = ((ch1 >= 'A') && (ch1 <= 'Z')) ? (ch1+32) : ch1;
const char cp2 = ((ch2 >= 'A') && (ch2 <= 'Z')) ? (ch2+32) : ch2;
if (cp1 < cp2)
return -1;
else if (cp1 > cp2)
return 1;
else if (cp1 == 0) /* they're both null chars? */
Apr 13, 2009
Apr 13, 2009
522
break;
Mar 15, 2007
Mar 15, 2007
523
524
} /* while */
Apr 13, 2009
Apr 13, 2009
525
return 0;
Mar 15, 2007
Mar 15, 2007
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
} /* __PHYSFS_stricmpASCII */
int __PHYSFS_strnicmpASCII(const char *str1, const char *str2, PHYSFS_uint32 n)
{
while (n-- > 0)
{
const char ch1 = *(str1++);
const char ch2 = *(str2++);
const char cp1 = ((ch1 >= 'A') && (ch1 <= 'Z')) ? (ch1+32) : ch1;
const char cp2 = ((ch2 >= 'A') && (ch2 <= 'Z')) ? (ch2+32) : ch2;
if (cp1 < cp2)
return -1;
else if (cp1 > cp2)
return 1;
else if (cp1 == 0) /* they're both null chars? */
return 0;
} /* while */
return 0;
Aug 20, 2010
Aug 20, 2010
546
} /* __PHYSFS_strnicmpASCII */
Mar 15, 2007
Mar 15, 2007
547
548
Nov 5, 2006
Nov 5, 2006
549
/* end of physfs_unicode.c ... */