[plt-scheme] bytes, chars, mzchars

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Thu Jan 10 08:26:32 EST 2008

At Thu, 10 Jan 2008 07:55:12 -0500, tom sgouros wrote:
> An extension I've written to mzscheme returns a byte-string array like
> this:
>     return scheme_make_sized_byte_string(outbuf,-1,1);
> Where outbuf is  an array of char values.
> I see that if outbuf contains \177, it displays as \277 after it's been
> returned, within the mzscheme environment.  I'm imagining that this is
> because mzscheme uses the UCS encoding internally.  Is that correct?

No. A byte string is just a char* (plus a length), with no encoding.
So, if `outbuf' has octal 177 in it, it should stay octal 177 in the
resulting Scheme byte string.

> For this application, I have a function that would like to receive a
> single (8-bit) char value.

I'd use an exact integer in [0,255] for that, which corresponds to the
`byte?' predicate in Scheme.


Posted on the users mailing list.