︙ | | |
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
|
#import "OFInvalidFormatException.h"
#import "OFOutOfMemoryException.h"
#import "OFOutOfRangeException.h"
#import "of_asprintf.h"
#import "unicode.h"
extern const of_char16_t of_iso_8859_2_table[];
extern const char16_t of_iso_8859_2_table[];
extern const size_t of_iso_8859_2_table_offset;
extern const of_char16_t of_iso_8859_3_table[];
extern const char16_t of_iso_8859_3_table[];
extern const size_t of_iso_8859_3_table_offset;
extern const of_char16_t of_iso_8859_15_table[];
extern const char16_t of_iso_8859_15_table[];
extern const size_t of_iso_8859_15_table_offset;
extern const of_char16_t of_windows_1251_table[];
extern const char16_t of_windows_1251_table[];
extern const size_t of_windows_1251_table_offset;
extern const of_char16_t of_windows_1252_table[];
extern const char16_t of_windows_1252_table[];
extern const size_t of_windows_1252_table_offset;
extern const of_char16_t of_codepage_437_table[];
extern const char16_t of_codepage_437_table[];
extern const size_t of_codepage_437_table_offset;
extern const of_char16_t of_codepage_850_table[];
extern const char16_t of_codepage_850_table[];
extern const size_t of_codepage_850_table_offset;
extern const of_char16_t of_codepage_858_table[];
extern const char16_t of_codepage_858_table[];
extern const size_t of_codepage_858_table_offset;
extern const of_char16_t of_mac_roman_table[];
extern const char16_t of_mac_roman_table[];
extern const size_t of_mac_roman_table_offset;
extern const of_char16_t of_koi8_r_table[];
extern const char16_t of_koi8_r_table[];
extern const size_t of_koi8_r_table_offset;
extern const of_char16_t of_koi8_u_table[];
extern const char16_t of_koi8_u_table[];
extern const size_t of_koi8_u_table_offset;
static inline int
memcasecmp(const char *first, const char *second, size_t length)
{
for (size_t i = 0; i < length; i++) {
unsigned char f = first[i];
|
︙ | | |
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
|
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
|
-
+
|
- initWithCString: (const char *)cString
encoding: (of_string_encoding_t)encoding
length: (size_t)cStringLength
{
self = [super init];
@try {
const of_char16_t *table;
const char16_t *table;
size_t tableOffset, j;
if (encoding == OF_STRING_ENCODING_UTF_8 &&
cStringLength >= 3 &&
memcmp(cString, "\xEF\xBB\xBF", 3) == 0) {
cString += 3;
cStringLength -= 3;
|
︙ | | |
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
|
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
|
-
+
|
[self release];
@throw e;
}
return self;
}
- initWithUTF16String: (const of_char16_t *)string
- initWithUTF16String: (const char16_t *)string
length: (size_t)length
byteOrder: (of_byte_order_t)byteOrder
{
self = [super init];
@try {
size_t j;
|
︙ | | |
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
|
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
|
-
+
|
size_t len;
/* Missing high surrogate */
if ((character & 0xFC00) == 0xDC00)
@throw [OFInvalidEncodingException exception];
if ((character & 0xFC00) == 0xD800) {
of_char16_t nextCharacter;
char16_t nextCharacter;
if (length <= i + 1)
@throw [OFInvalidEncodingException
exception];
nextCharacter = (swap
? OF_BSWAP16(string[i + 1])
|
︙ | | |
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
|
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
|
-
+
|
[self release];
@throw e;
}
return self;
}
- initWithUTF32String: (const of_char32_t *)characters
- initWithUTF32String: (const char32_t *)characters
length: (size_t)length
byteOrder: (of_byte_order_t)byteOrder
{
self = [super init];
@try {
size_t j;
|
︙ | | |
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
|
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
|
-
+
-
+
|
ret[j++] = c;
i += cLen;
}
return ret;
}
- (const of_char32_t *)UTF32StringWithByteOrder: (of_byte_order_t)byteOrder
- (const char32_t *)UTF32StringWithByteOrder: (of_byte_order_t)byteOrder
{
OFObject *object = [[[OFObject alloc] init] autorelease];
of_char32_t *ret;
char32_t *ret;
size_t i, j;
ret = [object allocMemoryWithSize: sizeof(of_unichar_t)
count: _s->length + 1];
i = j = 0;
|
︙ | | |