mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
This adds Unicode 9 grapheme breaking support for non-contiguous NSStrings. Non-contiguous NSStrings that don't hit our fast paths are very rare, but should still behave identically to contiguous strings. We first copy a fixed number of code units into a fixed size buffer (currently 16 in size) and try to grapheme break inside of that buffer. This is sufficient storage for all known non-pathological graphemes. Any graphemes larger than the buffer are handled by copying larger portions of the string into an Array. Test cases added, including pathological "zalgo" text that stresses extremely long graphemes.
11 lines
219 B
Objective-C
11 lines
219 B
Objective-C
#import <Foundation/NSString.h>
|
|
|
|
// An NSString whose _fastCharacterContents always returns nil
|
|
@interface NSSlowString : NSString
|
|
|
|
@property (nonatomic, strong) id myProperty;
|
|
|
|
- (void *) _fastCharacterContents;
|
|
|
|
@end
|