On 24 July 2018 at 02:38, Denis Kudriashov <dionisiydk@gmail.com> wrote:
2018-07-23 19:19 GMT+01:00 Alistair Grant <akgrant0710@gmail.com>:
Hi Pavel & Sven,
Thanks for writing this, it is a great quick reference.
On Mon, 23 Jul 2018 at 12:08, Sven Van Caekenberghe <sven@stfx.eu> wrote:
On 23 Jul 2018, at 11:13, Ben Coman <btc@openinworld.com> wrote:
I like all the new code examples until "Write a UTF-8 text to STDOUT" and I wonder "Stdio stdout writeStreamDo: [ :stream | stream nextPutAll: 'a â b' ]" would better fit the pattern of the other new code. (presuming "Stdio stdout" returns a FileReference, oherwise maybe "Stdio stdoutRef" or "Stdio stdout asFileReference")
Stdio stdout and friends just return a binary stream, hence they need wrapping for encoding.
Maybe
Stdio stdoutAsText
might be an idea, but this is so uncommon that I am not sure this is a good idea.
I've written this code enough times that I'd like to see it included. :-)
Maybe
Stdout utf8Stdout
(following the pattern of ByteArray>>utf8Decoded, String>>utf8Encoded)
?
Thanks again, Alistair
I wonder does not stdout and stdin are always about text input/output? I never saw examples when somebody explicitly write raw bytes into these streams.
Its done... https://subosito.com/posts/imagemagick/ but I guess its not the usual case.
If I am right then it is better to introduce binaryStdout and binaryStdin messages. And make stdout and stdin use most common encoding by default. How it is done in Java?
It might be nice to further the new convention "use file references as entry points to file streams" so the new API can be reused... StdioRef stdout writeStreamDo: [ :stream | stream nextPutAll: 'a â b' ]. StdioRef stdout writeStreamEncoded: 'cp-1250' do: [ :stream | stream nextPutAll: 'PÅÃliÅ¡ žluÅ¥ouÄký kůŠúpÄl Äábelské ódy.' ]. StdioRef stdout binaryWriteStreamDo: [ :stream | stream nextPutAll: #[1 2 3] ]. cheers -ben