Skip to content

Incorrect cursor_range Calculation in Ime::Preedit #3967

@mitoma

Description

@mitoma

Description

When using the Japanese IME (Microsoft IME) with winit, the cursor_range value in Ime::Preedit(text, cursor_range) becomes corrupted.

For example, when trying to convert the string “ぶたがなく” within the range of “ぶたが”, the cursor_range should ideally be "(start)🐖が(end)なく". However, it ends up being "(start)🐖がな(end)く", with the (end) position being off by one character.

This issue arises because the character “🐖” is passed as a UTF-16 surrogate pair in Windows. Although the cursor position attribute is also based on UTF-16, winit’s calculation of cursor_range does not account for surrogate pairs.

Please update the cursor_range calculation to handle surrogate pairs correctly.

Windows version

Microsoft Windows [Version 10.0.22631.4317]

Winit version

In versions 0.28.1 and later

Metadata

Metadata

Assignees

No one assigned

    Labels

    B - bugDang, that shouldn't have happenedDS - win32Affects the Win32/Windows backend

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions