Differences From Artifact [be8ebf571d]:
- File src/OFString_UTF8.m — part of check-in [7e5c81e186] at 2018-01-03 19:49:46 on branch trunk — Update copyright notice (user: js, size: 30507) [annotate] [blame] [check-ins using]
To Artifact [d6a602d281]:
- File
src/OFString_UTF8.m
— part of check-in
[505137f25f]
at
2018-02-25 04:31:30
on branch trunk
— Reintroduce of_char{16,32}_t
There is no reliable way to check if C++ already defined those, as Clang
now defines char{16,32}_t even when it is not in C++ 11 mode. So we
cannot check if we are not in C++ 11 and then define them and otherwise
rely on the C++ 11 types. (user: js, size: 30558) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
36 37 38 39 40 41 42 | #import "OFInvalidFormatException.h" #import "OFOutOfMemoryException.h" #import "OFOutOfRangeException.h" #import "of_asprintf.h" #import "unicode.h" | | | | | | | | | | | | | 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 68 69 70 | #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 size_t of_iso_8859_2_table_offset; extern const of_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 size_t of_iso_8859_15_table_offset; extern const of_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 size_t of_windows_1252_table_offset; extern const of_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 size_t of_codepage_850_table_offset; extern const of_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 size_t of_mac_roman_table_offset; extern const of_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 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]; |
︙ | ︙ | |||
230 231 232 233 234 235 236 | - (instancetype)initWithCString: (const char *)cString encoding: (of_string_encoding_t)encoding length: (size_t)cStringLength { self = [super init]; @try { | | | 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 | - (instancetype)initWithCString: (const char *)cString encoding: (of_string_encoding_t)encoding length: (size_t)cStringLength { self = [super init]; @try { const of_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; |
︙ | ︙ | |||
510 511 512 513 514 515 516 | [self release]; @throw e; } return self; } | | | 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 | [self release]; @throw e; } return self; } - (instancetype)initWithUTF16String: (const of_char16_t *)string length: (size_t)length byteOrder: (of_byte_order_t)byteOrder { self = [super init]; @try { size_t j; |
︙ | ︙ | |||
546 547 548 549 550 551 552 | size_t len; /* Missing high surrogate */ if ((character & 0xFC00) == 0xDC00) @throw [OFInvalidEncodingException exception]; if ((character & 0xFC00) == 0xD800) { | | | 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 | size_t len; /* Missing high surrogate */ if ((character & 0xFC00) == 0xDC00) @throw [OFInvalidEncodingException exception]; if ((character & 0xFC00) == 0xD800) { of_char16_t nextCharacter; if (length <= i + 1) @throw [OFInvalidEncodingException exception]; nextCharacter = (swap ? OF_BSWAP16(string[i + 1]) |
︙ | ︙ | |||
595 596 597 598 599 600 601 | [self release]; @throw e; } return self; } | | | 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 | [self release]; @throw e; } return self; } - (instancetype)initWithUTF32String: (const of_char32_t *)characters length: (size_t)length byteOrder: (of_byte_order_t)byteOrder { self = [super init]; @try { size_t j; |
︙ | ︙ | |||
1279 1280 1281 1282 1283 1284 1285 | ret[j++] = c; i += cLen; } return ret; } | | | | 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 | ret[j++] = c; i += cLen; } return ret; } - (const of_char32_t *)UTF32StringWithByteOrder: (of_byte_order_t)byteOrder { OFObject *object = [[[OFObject alloc] init] autorelease]; of_char32_t *ret; size_t i, j; ret = [object allocMemoryWithSize: sizeof(of_unichar_t) count: _s->length + 1]; i = j = 0; |
︙ | ︙ |