Skip to content

-STDIN skips a UTF-8 BOM before the first path (4.2.46) - #802

Merged
ddehilster merged 1 commit into
VisualText:masterfrom
ddehilster:fix/stdin-bom
Oct 26, 2026
Merged

ddehilster merged 1 commit into
VisualText:masterfrom
ddehilster:fix/stdin-bom

Conversation

@ddehilster

@ddehilster ddehilster commented Oct 26, 2026 •

Copy link
Copy Markdown
Member

Problem

When a .NET program starts nlp -STDIN with stdin redirected, nlp silently skips the first input file. That includes C# programs and PowerShell scripts that go through System.Diagnostics.Process. .NET writes the UTF-8 byte-order mark (EF BB BF) of Console.InputEncoding into the pipe as soon as the process starts, before the caller writes anything. -STDIN then read the first line as \uFEFFC:\...\a.txt and reported

[stream: no such input file: a.txt]

It carried on with the rest, so the run ended one input short.

I found this while streaming 2,509 pieces of a book through -STDIN from PowerShell for the zoning experiment: every run was one piece short.

Fix

analyzeStream drops a UTF-8 BOM at the start of the first line only. A BOM can only appear at the start of a stream.

Tests

  • The -STDIN CI step on Windows and Linux now also sends a.txt b.txt c.txt with a BOM in front, and expects all three analyzed with the right first and last flags. macOS has no -STDIN step.
  • Run locally on this branch, the step passes. With a master build it fails: a.txt is reported missing and only two inputs are analyzed.
  • All 53 Windows fixture steps pass locally.

Version 4.2.46 (rebased onto 4.2.45, zone mode). #803 follows as 4.2.47; I plan to release both under one tag, because of the PyPI size limit.

🤖 Generated with Claude Code

A .NET program that starts nlp with stdin redirected (C#, or PowerShell
through System.Diagnostics.Process) writes Console.InputEncoding's UTF-8
BOM into the pipe as soon as the process starts, before the caller writes
anything. -STDIN read the first line as "C:\...\a.txt", reported

  [stream: no such input file: a.txt]

and went on with the rest, so the first input was silently not analyzed.
Found while streaming 2,509 pieces of a book through -STDIN from
PowerShell: every run was one piece short.

analyzeStream now drops a UTF-8 BOM at the start of the first line only.

CI: the -STDIN step on Windows and Linux (macOS has no -STDIN step) now
also sends the three paths with a BOM in front and expects all three
analyzed. On master it analyzes two.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ddehilster ddehilster changed the title -STDIN skips a UTF-8 BOM before the first path (4.2.43) -STDIN skips a UTF-8 BOM before the first path (4.2.46) Oct 26, 2026
@ddehilster
ddehilster merged commit 2f8bd4f into VisualText:master Oct 26, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant