Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

do streams for bytes and strings exist?

38 views
Skip to first unread message

Florian Dietz

unread,
Oct 26, 2012, 5:50:09 AM10/26/12
to
I am writing a serializer for some objects and I can't seem to be able to write and read both bytes and strings to the file. It's an either-or question, depending on what type of stream I take.

Am I overlooking something? What is the best way to do this?

Zach Beane

unread,
Oct 26, 2012, 7:07:08 AM10/26/12
to
There is no standard way. Many implementations support "bivalent
streams" that can take both binary and character operations. In the
absence of bivalent streams, it's typical to use a binary stream (with
an element type of (unsigned-byte 8)) and convert characters and strings
to the appropriately encoded octet vector before writing them to the
stream.

Zach

Frode V. Fjeld

unread,
Oct 26, 2012, 7:35:34 AM10/26/12
to
I'd suggest using the FLEXI-STREAMS library.

--
Frode V. Fjeld

Florian Dietz

unread,
Oct 26, 2012, 8:45:11 AM10/26/12
to
Thanks, I went with this and wrote some macros.

Zach Beane

unread,
Oct 26, 2012, 8:47:52 AM10/26/12
to
Frodef's suggestion is good, too. Flexi-streams are handy.

Zach
0 new messages