Differences From Artifact [29e52abbc7]:
- File src/OFMutableString.m — part of check-in [13f4c6c678] at 2016-09-12 00:27:14 on branch trunk — Add OF_DEALLOC_UNSUPPORTED macro (user: js, size: 13867) [annotate] [blame] [check-ins using]
To Artifact [3b4d8b06cc]:
- File
src/OFMutableString.m
— part of check-in
[d9eb7b50b3]
at
2017-01-07 00:37:26
on branch trunk
— Add of_ascii_{to{upper,lower},is{alpha,alnum}}
These are independent of the locale and work on the ASCII character set.
Unlike the C ones, these are 8-bit safe, meaning if a character > 0x7F
is passed, is{alpha,alnum} returns false and to{upper,lower} returns the
original character. (user: js, size: 13690) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
33 34 35 36 37 38 39 | #import "of_asprintf.h" #import "unicode.h" static struct { Class isa; } placeholder; | < < < < < < < < < < < < < < < | 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | #import "of_asprintf.h" #import "unicode.h" static struct { Class isa; } placeholder; @interface OFMutableString_placeholder: OFMutableString @end @implementation OFMutableString_placeholder - init { return (id)[[OFMutableString_UTF8 alloc] init]; |
︙ | ︙ | |||
293 294 295 296 297 298 299 | break; } } objc_autoreleasePoolPop(pool); } #else | | | | | 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 | break; } } objc_autoreleasePoolPop(pool); } #else - (void)OF_convertWithWordStartFunction: (char (*)(char))startFunction wordMiddleFunction: (char (*)(char))middleFunction { void *pool = objc_autoreleasePoolPush(); const of_unichar_t *characters = [self characters]; size_t length = [self length]; bool isStart = true; for (size_t i = 0; i < length; i++) { char (*function)(char) = (isStart ? startFunction : middleFunction);; of_unichar_t c = characters[i]; if (c <= 0x7F) [self setCharacter: (int)function(c) atIndex: i]; |
︙ | ︙ | |||
480 481 482 483 484 485 486 | wordMiddleTable: of_unicode_lowercase_table wordStartTableSize: OF_UNICODE_TITLECASE_TABLE_SIZE wordMiddleTableSize: OF_UNICODE_LOWERCASE_TABLE_SIZE]; } #else - (void)uppercase { | | | | | | | | 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 | wordMiddleTable: of_unicode_lowercase_table wordStartTableSize: OF_UNICODE_TITLECASE_TABLE_SIZE wordMiddleTableSize: OF_UNICODE_LOWERCASE_TABLE_SIZE]; } #else - (void)uppercase { [self OF_convertWithWordStartFunction: of_ascii_toupper wordMiddleFunction: of_ascii_toupper]; } - (void)lowercase { [self OF_convertWithWordStartFunction: of_ascii_tolower wordMiddleFunction: of_ascii_tolower]; } - (void)capitalize { [self OF_convertWithWordStartFunction: of_ascii_toupper wordMiddleFunction: of_ascii_tolower]; } #endif - (void)insertString: (OFString*)string atIndex: (size_t)index { [self replaceCharactersInRange: of_range(index, 0) |
︙ | ︙ |