Preserve valid code units after malformed UTF-16 · Issue #209 · gulrak/filesystem · GitHub
Skip to content

Preserve valid code units after malformed UTF-16 #209

Description

@gulrak

The UTF-16 overload of detail::toUtf8() advances to the next code unit as soon as it encounters any surrogate. If the surrogate is not the start of a valid high/low pair, that next code unit has already been consumed.

For example, converting a high surrogate followed by A in replacement mode currently emits only U+FFFD and silently drops the valid A. An isolated low surrogate has the same problem with the code unit following it.

Expected behaviour

  • Consume two UTF-16 code units only for a valid high/low surrogate pair.
  • In replacement mode, emit U+FFFD for each malformed surrogate and continue converting all subsequent valid code units.
  • With GHC_RAISE_UNICODE_ERRORS, continue to report malformed UTF-16 as an illegal byte sequence.
  • Keep valid surrogate-pair conversion unchanged.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

available on masterFix is done on master branch, issue closed on next releasebugSomething isn't working

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions