Skip to content

trim_partial_utf16() should handle length=1 regularly #829

@Scorg

Description

@Scorg

Right now that function has a special case for length <= 1, when it returns the passed length as is, disregarding a potential case of single partial surrogate code unit. To handle this, the user has to either special case length <= 1 and call validate_utf16_with_errors(), and then use the returned .count value; or simply call validate_utf16_with_errors() right away and get the length from that. This makes that function kinda useless.

I haven't done an exhaustive testing, but from a quick glance at the code, the utf8 variant handles single-character strings properly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions