[squeak-dev] Binary Read Streams from base64 decoded (ReadStream >> #binary ??)

Jakob Reschke forums.jakob at resfarm.de
Sun Nov 22 15:47:28 UTC 2020


Hi Eric,

If you don't want to use RWBinaryOrTextStream or asBinaryOrTextStream,
you could try: aString base64Decoded asByteArray readStream.

Traditionally, Smalltalk file streams are either in text (ascii) or
binary mode, returning either bytes or characters when you read from
the stream. #binary is the selector to put a file stream in binary
mode. It has no effect on ReadStream, which is just a stream adapter
on a Collection, not a file stream. The ReadStream will always return
the elements of the collection, no conversion going on. ReadStream
implements binary just so you can put one into a method that expects a
file stream.

Kind regards,
Jakob

Am So., 22. Nov. 2020 um 16:12 Uhr schrieb Eric Gade <eric.gade at gmail.com>:
>
> Hi all,
>
> I have some code I'm trying to make cross platform. In one of my classes, I store bits describing a Form as a base64 encoded string. Pharo has dramatically changed their streams in recent years, so on that end this simply works:
>
> `PNGReadWriter formFromStream: (self formSource base64Decoded readStream)`
>
> In Squeak the readStream produced will be a textual stream, which is somewhat understandable. But when I look at ReadStream >> #binary , I see that the method is empty. Is this on purpose? The only other recourse I can find is to send the message #asBinaryOrTextStream, but this breaks compatibility with Pharo, so I was hoping for a more straightforward solution.
>
> Any ideas?
>
> --
> Eric
>


More information about the Squeak-dev mailing list