[plt-scheme] strings?

From: Mike (mikee at mikee.ath.cx)
Date: Sat Apr 16 12:58:34 EDT 2005

On Fri, 15 Apr 2005, Matthew Flatt might have said:

>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme
> At Fri, 15 Apr 2005 08:16:37 -0500, Mike wrote:
> >     if(!SCHEME_CHAR_STRINGP(argv[0])) {
> >         scheme_wrong_type("sqlite:open", "string", 0, argc, argv);
> >     }
> >     dbname = SCHEME_BYTE_STR_VAL(argv[0]);
> SCHEME_BYTE_STR_VAL() should be used only on a value for which
> SCHEME_BYTE_STRINGP() produces true.
> SCHEME_CHAR_STR_VAL() should be used only on a value for which
> SCHEME_CHAR_STRINGP() produces true.
> The result of SCHEME_CHAR_STR_VAL() is a mzchar*, so I can see why
> you're trying to use SCHEME_BYTE_STR_VAL() to get a char*, but it
> doesn't work. (The actual layout of byte string and char string values
> means that, on a little-endian machine, you end up with one byte when
> trying to use a char string as a byte string. But that's just an
> artifact of the current data layout.)
> To turn a char string into a byte string, you can use
> scheme_char_string_to_byte_string() or
> scheme_char_string_to_byte_string_locale(), depending on whether you
> want a UTF-8 or locale-based encoding of the string.
> Matthew

Thanks for the explanation. I'm still lost.
I accept that mzscheme uses a multibyte representation internally,
and that the use of scheme strings works internally. I want to
extract a string from inside mzscheme and give that string
as a null-terminated string to a C function. That function
could be (and is) sqlite_open() or ot could be fopen() for
opening a file for custom processing, etc.

How do I extract the string from mzscheme to give to the C function?

Mike (the dense one)

Posted on the users mailing list.