[I6] Adapting Glulx code to handle Unicode

In a recent bug report for the Vorple for I6 libraries (https://github.com/vorple/inform6/issues/22), I realized the problem was that the functions used werent handling unicode (the functions dont have the _uni suffix).

In order to fix this, is it as simple as changing the relevant functions to their _uni counterparts? (If so, it would only create problems if I forgot one presumably?)

Or do I need to do that + change my array types? (How do i declare an array type of a certain length?)
Or is there something else that needs to be done?


1 Like

I don’t know what the Vorple code is doing in there. But the I6 part of the answer is that glk_stream_open_memory uses byte arrays, but glk_stream_open_memory_uni uses word arrays. So declare the array you pass in with --> instead of ->, and then use --> to access its contents.

1 Like

Thank you zarf. And the length of what is in the array (or was printed inside the array) has to be saved from the last argument of stream_close, right? (There’s no equivalent for the -->0 of buffer arrays?)

Correct. Neither glk_stream_open_memory nor glk_stream_open_memory_uni uses the “zeroth element is the length” convention. (Although some parts of the parser do.)

I have a related question… How can I tell (or is it even possible) from within I6 if an array is a word array or a byte array?
I have run into a bit of a snag and it would really help if I could write a routine that can handle both word arrays and byte arrays; but I don’t really know what to put in my “if” statement that’d make that distinction…

Not as far as I know. That information is only used when you declare an array.

Right, you can’t tell. Even if you could, it would be unwise to rely on it. Really it’s legal to use either the -> or --> operators with either byte or word arrays, as long as you’re careful about the math and don’t overflow.