[Accepted] SE-0241: Explicit Encoded Offsets for String Indices

The review of SE-0241 has concluded.

Feedback on the initial proposal was mostly positive, but several people expressed some reservations about some of the new API, and the authors agreed to reduce the proposal to a more minimal change. That new version generally met with approval, with a few dissents:

  • Some community members took the opportunity to register their disapproval of the lack of integer indexing into String. While those complaints are noted, this review was not the place to air them.

  • Lily Ballard expressed concern about the lack of structure of these encoded offsets and about their behavior when the offset does not correspond to a scalar boundary. The Core Team generally agrees with the proposal author that the offset not matching a scalar boundary is a programmer error for which trapping is consistent with Swift's general behavior on similar precondition violations.

Therefore, SE-0241 is accepted.

As always, thank you for participating in the evolution process.


Technically, this is not quite the scenario that's an issue. A sub-scalar UTF-16 offset is totally valid and will result in an index referencing the second surrogate in the pair, and vice versa. The programmer error is asking for the UTF-16 offset corresponding to a sub-scalar UTF-8 index.

1 Like