[swift-evolution] Pitch: String Index Overhaul

Brent Royal-Gordon brent at architechies.com
Fri Jun 2 18:37:01 CDT 2017


> On May 27, 2017, at 10:40 AM, Dave Abrahams via swift-evolution <swift-evolution at swift.org> wrote:
> 
> A property and an intializer will be added to `String.Index`, exposing
> the offset of the index in code units (currently only UTF-16) from the
> beginning of the string:
> 
> ```swift
> let n: Int = html.endIndex.encodedOffset
> let end = String.Index(encodedOffset: n)
> assert(end == String.endIndex)
> ```


Do you intend to allow users to serialize an `encodedOffset` and deserialize it later, perhaps in a later version of Swift, to represent the same position? If so, I'm not sure how you intend to maintain compatibility once the "currently only UTF-16" notation is no longer true.

-- 
Brent Royal-Gordon
Architechies

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170602/ee4aec3d/attachment.html>


More information about the swift-evolution mailing list