Differences From Artifact [9492a9e3d8]:
- File
src/OFMutableString_UTF8.m
— part of check-in
[4d892e0db1]
at
2013-07-04 20:49:52
on branch trunk
— Fix -[replaceCharactersInRange:withString:].
The resizing is now done before the memmove() if the new string is
bigger and after the memmove() if the new string is shorter. The added
comment explains why this is necessary.This also adds a test for -[replaceCharactersInRange:withString:] that
makes the string bigger and another one that makes it smaller again. (user: js, size: 20151) [annotate] [blame] [check-ins using]
To Artifact [be6d727813]:
- File src/OFMutableString_UTF8.m — part of check-in [f177032b43] at 2013-11-23 17:28:18 on branch trunk — OF(Mutable)String_UTF8: Code simplification. (user: js, size: 19884) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
391 392 393 394 395 396 397 | tmp = [self allocMemoryWithSize: (length * 4) + 1]; @try { size_t i, j = 0; bool isUTF8 = false; for (i = 0; i < length; i++) { | < < | < | < < < < | | < < < < < | < < < | < < < < < | 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 | tmp = [self allocMemoryWithSize: (length * 4) + 1]; @try { size_t i, j = 0; bool isUTF8 = false; for (i = 0; i < length; i++) { size_t len = of_string_utf8_encode(characters[i], tmp + j); if (len == 0) @throw [OFInvalidEncodingException exception]; if (len > 1) isUTF8 = true; j += len; } tmp[j] = '\0'; _s->hashed = false; _s->cString = [self resizeMemory: _s->cString size: _s->cStringLength + j + 1]; |
︙ | ︙ |