[swift-evolution] Int indexing into UTF16View
jordan_rose at apple.com
Mon Jun 12 17:47:29 CDT 2017
> On Jun 10, 2017, at 19:01, Charles Srstka via swift-evolution <swift-evolution at swift.org> wrote:
>> On Jun 8, 2017, at 2:35 PM, Tony Allevato via swift-evolution <swift-evolution at swift.org> wrote:
>> It is an extremely rare case for a developer to know a priori what literal numeric indices should be used when indexing into a string, because it only applies when strings fall into a very specific format and encoding.
> Knowing this is required for accessibility support on macOS, since it’s needed to implement NSAccessibility methods such as accessibilityAttributedString(for:), accessibilityRTF(for:), accessibilityFrame(for:), etc.
I think Tony was getting at knowing the best indices for a string, vs. a format or API that is documented to use UTF-8 or UTF-16 indexes specifically (like, unfortunately, most of Cocoa and Cocoa Touch). It stinks that those may not be random-access if the underlying string buffer turns out to not be UTF-16, but that's true with NSString as well.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the swift-evolution