Some years ago I ported a Ruby gem to #Scheme to detect the image type and dimensions without using libmagic. I've recently found out the test suite fails on Windows with an EOF error when run on specific PNG and JPEG files.

Today I've discovered that the culprit was `call-with-input-file` defaulting to text mode on Windows and requiring the use of the `#:binary` flag, otherwise only as little as five bytes can be read when processing a PNG file.

Why five? Well, it turns out that the PNG format employs several tricks in its file signature to avoid incorrect file processing: Mission accomplished I guess. I wonder how many of my Scheme programs I need to adjust to work correctly on these forsaken systems defaulting to text mode... Is there even a reason to use or support it?

@wasamasa these days, it would seem Windows programs are generally able to handle files with LF line endings, with even notepad being fixed a few years back.

I think we can conclude that LF line endings won, and software (in particular libraries) should simply use binary, with all text being written with LF, unless special options are passed.

@loke @wasamasa I expect we'll have to handle both for quite some time, as the MIME text/* types stipulate CRLF line endings.


@bkhl @wasamasa Well, true. But we already handle those specially anyway since most code that runs on webservers are on Linux anyway.

Sign in to participate in the conversation
Functional Café

The social network of the future: No ads, no corporate surveillance, ethical design, and decentralization! Own your data with Mastodon!