Glulxe fatal error: String argument to a Glk call must be unencoded

Receiving error:

Glulxe fatal error: String argument to a Glk call must be unencoded

I’m assuming this is an Inform to UTF8 issue. Just not sure how I would go about unencoding my Inform string so I can pass it properly to a Glk call.

Many thanks!

Strings in Glulx can be one-byte sequences, four-byte sequences, or compressed: see section 1.6.1 of the Glulx specification. Note that the Glulx specification does not define the encoding of these strings.

The Glk dispatch layer can handle one-byte sequence strings, which are assumed to be ISO-Latin-1, or four-byte sequences, which are assumed to be Unicode code points. It does not handle compressed strings. This is what the error is about.

You can just tell Inform to turn off string compression (see the -H flag). I don’t recall if there’s a way to control whether an individual string is compressed or not.

Happy to turn it off entirely if it saves the trouble! What are the consequences of doing so?

Having never tried that, I’m not entirely sure. But all strings would be uncompressed so readable with a binary editor, for a start.

It does, really – it defines strings as not being encoded at all. Strings are sequences of integers representing Unicode code points. (Byte strings, tagged E0, can only contain integers 0-255. But each one is still a Unicode code point.)

The -H flag was never really meant for real-world use. It’s left over from when I was implementing the Glulx side of the compiler and didn’t have string compression working yet.

What call are you making that requires a string? If you’re printing text, you can do that through Glulx without having to worry about any of this.

If I recall, I was mucking about with this code:

! TODO: Figure out what these two lines do and why the  +3 is used in the function call
        buffer->3 = $E0;

        !print "buffer2: ", (StringOrArray)createFileReferenceBuffer, "^";

        buffer->(4 + nameLength) = 0;

        ! print "buffer3: ", (StringOrArray)createFileReferenceBuffer, "^";

        ! (This is a type-data, binary file.)
        fileReference = glk_fileref_create_by_name(fileusage_BinaryMode, buffer + 3, 0);

I think to figure out what the = $E0 and other related lines before the create_by_name call, and I think I commented them out and the call gave the error from the OP…

You’ve already answered the $E0 question, I suspect the “= 0” statement is similar to a null-termination.

Yep, exactly.