Skip to content

Windows console write uses wrong low surrogate range (0xDCEE instead of 0xDC00) #377

@SebTardif

Description

@SebTardif

Bug

In library/std/src/sys/stdio/windows.rs, the low surrogate detection range is 0xDCEE..=0xDFFF instead of the correct 0xDC00..=0xDFFF.

This misses surrogates 0xDC00 through 0xDCED, causing:

  • The trailing low surrogate of a split surrogate pair to not be flushed
  • The UTF-8 byte count calculation to be wrong (counts 3 bytes instead of 1 for the low surrogate portion)
  • The Write trait to report fewer bytes written than consumed

Affects supplementary Unicode characters (emoji, CJK Extension B, mathematical symbols) written to the Windows console when the write buffer splits mid-surrogate pair.

Fix

Change both instances of 0xDCEE to 0xDC00 to cover the full low surrogate range.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-ioI/O, stdio, buffered readersI-wrongWrong result or data corruptionO-windowsWindows-specificP-mediumMedium impact: affects specific usage patterns

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions