Skip to content

'𠮷'.length should return 1 instead of 2 #1428

Closed
@Cat-sushi

Description

@Cat-sushi

I understand that this is a kind of massive breaking change, and I'm looking for a migration path, but haven't found one yet.

As you can see, current String.length is confusing and harmful especially for non-english speakers.
I believe there are almost no correct usage of current String.length, because we can't manipulate String with it correctly.
The root cause of this is that String is sequence of ints representing code units but not code points even at surface of the API.
So, this proposal include introducing Rune (not Runes) as int representing a code point and changing String as a sequence of Runes at least from view point of API.
This proposal might also include deprecating current operator [] of String and introducing runeAt() to String.
Don't misunderstand me, I don't assert that the internal representation of String should be sequence of code points, by this proposal.

Metadata

Metadata

Assignees

No one assigned

    Labels

    requestRequests to resolve a particular developer problem

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions