Class ByteOrderMarkSkippingInputStream
- All Implemented Interfaces:
Closeable, AutoCloseable
ek9 -mcp, ek9 -ls, ek9 -dap): the
stream it is given, with a UTF-8 byte order mark (EF BB BF) at its very START consumed and discarded.
Use it - never a private BOM check in one server.
Why: Windows PowerShell 5.1's .NET writes a byte order mark into a child's stdin the moment the child starts
when the console's input encoding is UTF-8 (measured 2026-11-15: ek9 -mcp then logged "malformed JSON:
Unexpected character (code 65279)" and never answered initialize). JSON-RPC has no byte order mark, so
one ahead of the first message can only be that, and skipping it makes the server answer the same from
PowerShell, a normal terminal, macOS and Linux.
The check is made once, lazily, on the first read - so constructing this never blocks - and only the first
three bytes are looked at: a stream that does not start with the whole mark is returned unchanged, byte for byte
(a partial EF or EF BB is pushed back). A byte order mark anywhere later is data and is left
alone.
-
Field Summary
Fields inherited from class PushbackInputStream
buf, posFields inherited from class FilterInputStream
in -
Constructor Summary
ConstructorsConstructorDescriptionThe streamin, its leading UTF-8 byte order mark (if any) skipped on the first read. -
Method Summary
Methods inherited from class PushbackInputStream
available, close, mark, markSupported, reset, transferTo, unread, unread, unreadMethods inherited from class FilterInputStream
readMethods inherited from class InputStream
nullInputStream, readAllBytes, readNBytes, readNBytes, skipNBytes
-
Constructor Details
-
ByteOrderMarkSkippingInputStream
The streamin, its leading UTF-8 byte order mark (if any) skipped on the first read.
-
-
Method Details
-
read
- Overrides:
readin classPushbackInputStream- Throws:
IOException
-
read
- Overrides:
readin classPushbackInputStream- Throws:
IOException
-
skip
- Overrides:
skipin classPushbackInputStream- Throws:
IOException
-