mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-11-10 01:56:15 +08:00
libuv's uv_fs_scandir sorts the raw directory-entry bytes with strcmp and decodes the names only after sorting. Sorting the decoded text instead reorders names that are not valid UTF-8: the malformed bytes 0x80 and 0xfe decode to U+FFFD, which sorts after "é", and distinct names that decode to the same text fall into an arbitrary order. readdir and readdirSync listed those names in an order Node never produces. scr_fs_scandir now collects the raw names, sorts them with strcmp, and then decodes each one into the ScrScandir. The malformed UTF-8 harness test also prints the unsorted readdir order and carries names whose byte order and decoded order differ. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>