> On Jun 10, 2017, at 19:01, Charles Srstka via swift-evolution > <swift-evolution@swift.org> wrote: > >> On Jun 8, 2017, at 2:35 PM, Tony Allevato via swift-evolution >> <swift-evolution@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. Jordan
_______________________________________________ swift-evolution mailing list swift-evolution@swift.org https://lists.swift.org/mailman/listinfo/swift-evolution