Differences From Artifact [b3064980ae]:
- File src/OFString_UTF8.m — part of check-in [9cfefe9c30] at 2012-10-13 20:50:09 on branch trunk — Move UTF-8 functions to OFString_UTF8.m. (user: js, size: 29614) [annotate] [blame] [check-ins using]
To Artifact [2e4dae0bbe]:
- File
src/OFString_UTF8.m
— part of check-in
[1cb8fee5c3]
at
2012-10-13 21:06:59
on branch trunk
— of_bswap* -> OF_BSWAP*.
This makes it clear that multiple evaluation of parameters is possible. (user: js, size: 29614) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
495 496 497 498 499 500 501 | s->cStringLength = length; s->cString = [self allocMemoryWithSize: (length * 4) + 1]; s->length = length; for (i = 0; i < length; i++) { char buffer[4]; size_t characterLen = of_string_utf8_encode( | | | 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 | s->cStringLength = length; s->cString = [self allocMemoryWithSize: (length * 4) + 1]; s->length = length; for (i = 0; i < length; i++) { char buffer[4]; size_t characterLen = of_string_utf8_encode( (swap ? OF_BSWAP32(string[i]) : string[i]), buffer); switch (characterLen) { case 1: s->cString[j++] = buffer[0]; break; case 2: |
︙ | ︙ | |||
577 578 579 580 581 582 583 | s->cStringLength = length; s->cString = [self allocMemoryWithSize: (length * 4) + 1]; s->length = length; for (i = 0; i < length; i++) { char buffer[4]; of_unichar_t character = | | | | 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 | s->cStringLength = length; s->cString = [self allocMemoryWithSize: (length * 4) + 1]; s->length = length; for (i = 0; i < length; i++) { char buffer[4]; of_unichar_t character = (swap ? OF_BSWAP16(string[i]) : string[i]); size_t characterLen; /* Missing high surrogate */ if ((character & 0xFC00) == 0xDC00) @throw [OFInvalidEncodingException exceptionWithClass: [self class]]; if ((character & 0xFC00) == 0xD800) { uint16_t nextCharacter; if (length <= i + 1) @throw [OFInvalidEncodingException exceptionWithClass: [self class]]; nextCharacter = (swap ? OF_BSWAP16(string[i + 1]) : string[i + 1]); character = (((character & 0x3FF) << 10) | (nextCharacter & 0x3FF)) + 0x10000; i++; s->cStringLength--; s->length--; |
︙ | ︙ |