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: en.wikipedia.org/wiki/Portable. 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.

Follow

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

· · Web · 1 · 0 · 0

@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
Mastodon @ SDF

"I appreciate SDF but it's a general-purpose server and the name doesn't make it obvious that it's about art." - Eugen Rochko