[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: binary vs non-binary ports

This page is part of the web mail archives of SRFI 56 from before July 7th, 2015. The new archives for SRFI 56 contain all messages, not just those from before July 7th, 2015.

Alex Shinn wrote:

> One interesting thing
> I discovered was that java.io.RandomAccessFile allows you to intermix
> reading characters and binary data on the same stream.

RandomAccessFile has limited accessability.  You could use it for
output-only ports, the standard input ports, network ports, or most
other ports you might want.

A possible way to get more portability is to go ahead and provide the
API for specifying port types, such as

How about:

(open-input-file path [encoding])
as in:
(open-input-file path "utf")
(open-input-file path "latin-1")

#t means "default encoding" (as specified by environment).
Thus (open-input-file path) == (open-input-file #t)
#f means "binary"

Kawa instead uses "fluid" variables, but I could easily
handle an extension like the above.

(I'm travelling so I'll have to answer more fully later.)
	--Per Bothner
per@xxxxxxxxxxx   http://per.bothner.com/