Skip to content

support unseekable streams: skip encoding detection - #7

Merged
xoofx merged 1 commit into
xoofx:mainfrom
djeikyb:support-unseekable-streams
Mar 12, 2026
Merged

xoofx merged 1 commit into
xoofx:mainfrom
djeikyb:support-unseekable-streams

Conversation

@djeikyb

@djeikyb djeikyb commented Mar 12, 2026

Copy link
Copy Markdown
Contributor

DetectEncodingOrNull requires a seekable stream. Encoding detection requires reading the first four bytes. The stream is advanced, then rewound. Fine for a FileStream, but not for a DeflateStream, as when the xml is being read with System.IO.Compression.ZipArchive.

SO. If the caller has provided an encoding: use it, skip trying to suss out the actual stream encoding, and absolutely avoid writing to the position property of the stream.

@xoofx
xoofx force-pushed the support-unseekable-streams branch from 8c54095 to 8b6adfb Compare March 12, 2026 18:53
DetectEncodingOrNull requires a seekable stream. Encoding detection
requires reading the first four bytes. The stream is advanced, then
rewound. Fine for a FileStream, but not for a DeflateStream, as when the
xml is being read with System.IO.Compression.ZipArchive.

SO. If the caller has provided an encoding: use it, skip trying to suss
out the actual stream encoding, and absolutely avoid writing to the
position property of the stream.
@xoofx
xoofx force-pushed the support-unseekable-streams branch from 8b6adfb to 3710753 Compare March 12, 2026 19:46
@xoofx
xoofx merged commit 9af7d60 into xoofx:main Mar 12, 2026
1 check passed
@xoofx

xoofx commented Mar 12, 2026

Copy link
Copy Markdown
Owner

Good catch, thank you!

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.

2 participants