| Item | Value |
|---|---|
| Console | A new cmd opened with conhost.exe (starts at 932). chcp 932 is not run |
| Bun | 1.4.2+744846f84 / 1.4.3-canary.1+bb35d1b81 |
| OS | Windows 11 Home 10.0.26300 |
| Script | tests/manual/issue-43660-repro.cmd <bun> <log> |
The script runs the following two lines in order. The two consoles (stable and canary) were opened at the same time.
bun -e "console.log('bun 2 bun 日本語')" | bun -e "process.stdin.pipe(process.stdout)"
bun -e "console.log('bun 2 bun 日本語')" | bun -e "process.stdin.pipe(process.stdout)" > log.bytes
Runs 1 and 2 wrote the chcp value to the log only. Run 3 wrote it to both the screen and the log, with ASCII labels.
After these three runs, the text in the script was changed to abc 東京大阪 xyz (so that no broken byte is left and the newline survives when garbled; see T5 in the plan). The results in this document were taken with the earlier bun 2 bun 日本語.
Results are listed in run order (run 1, 2, 3). ✅ as expected / ❌ not as expected / ⚠️ only the input side was back at 932 (chcp shows 932 but the message is in English) / ⬜ not checked (the screen of run 2 was not looked at).
| Check | 1.4.2 | 1.4.3-canary.1 |
|---|---|---|
| Text on screen | ❌⬜❌ | ❌⬜✅ |
| Code page after the console run | ❌❌✅ | ⚠️❌✅ |
| Code page after the file run | ❌❌✅ | ❌❌❌ |
| Bytes written to the file | ❌❌✅ | ❌❌✅ |
1.4.2+744846f84
[1] before
現在のコード ページ: 932
--- bun to bun, output to console ---
bun 2 bun 譌・譛ャ隱・[2] after console run
現在のコード ページ: 932
--- bun to bun, output to file ---
[3] after file run
現在のコード ページ: 932
--- end ---
続行するには何かキーを押してください . . .
1.4.3-canary.1+bb35d1b81
[1] before
現在のコード ページ: 932
--- bun to bun, output to console ---
bun 2 bun 日本語
[2] after console run
現在のコード ページ: 932
--- bun to bun, output to file ---
[3] after file run
Active code page: 65001
--- end ---
Press any key to continue . . .
現在のコード ページ is the Japanese form of Active code page, and 続行するには何かキーを押してください is the Japanese form of Press any key to continue. Windows prints the English form when the output code page is 65001.
| Run | The Japanese part |
|---|---|
| Runs 1 and 2 (both builds) | ef bf bd ef bf bd ef bf bd 7b ef bf bd ef bf bd (U+FFFD and {) |
| Run 3 (both builds) | e6 97 a5 e6 9c ac e8 aa 9e (correct UTF-8) |
We first read the broken bytes of runs 1 and 2 as "the data flowing through the Bun pipe is corrupted". That was wrong.
日本語 is not valid UTF-8, so Bun received U+FFFDThe broken bytes are evidence that cmd in the same console misread its own script because of the code page Bun left behind. The garbled Japanese labels in runs 1 and 2 have the same cause.
Not yet verified. If each Bun process "saves the current value and sets 65001 at start, and restores the saved value at exit", every observation is explained.
譌・譛ャ隱・ in 1.4.2 run 3 is the UTF-8 e6 97 a5 e6 9c ac e8 aa 9e read as CP932. The final 9e is taken as the lead byte of a double-byte character and swallows the following newline as ・, so the newline also disappears. This suggests the reader writes raw UTF-8 bytes to the console instead of using WriteConsoleW.
pause message)