/ swift Public
[SR-9749] The encodedOffset of String.Index has been changed to either UTF-8 or UTF-16. #52180
A deviation from expected or documented behavior. Also: expected but undesirable behavior.
Area: standard library umbrella
Additional Detail from JIRA
The problem is:
Before merging [String] Use a UTF-8 representation for native strings #20315, The encodedOffset of
String.Indexwas specified as UTF-16 offset, and it actually worked as expected.
A lot of codes were written that expect that behavior (including swift-corelibs-foundation)
e.g. codes using
encodedOffsetin Swift on GitHub can be found: https://github.com/search?l=Swift&q=encodedOffset&type=Code
However, the change is not written in changelog etc., and it is understood only from the description of UTF-16 deleted from each documentation comment. In fact, swift-corelibs-foundation did not recognize that change was necessary, which caused SR-9454.
I think that some countermeasures are necessary:
[MUST] Behavior changes should be documented (eg within changelog).
[MAY] Some code change
Introduce new property exposing encode information(UTF-8 or UTF-16) to
The text was updated successfully, but these errors were encountered: