I'm a bit lost on how al_ref_ustr is supposed to work.
If it specifies an end point, I assume it's meant to only return chars until the specified end, right?
I expected:
Char: 34
I got:
Char: 34567890
If this isn't the case, which function should I use instead then?
Your al_ref_ustr is fine, the problem is that you can't always convert a ustr to a cstr just with al_cstr. The reason is that al_ref_ustr has to create a substring from text_typed without altering text_typed, but a cstr is only a pointer to char, and the only way to figure out its length is to scan for the \0. So printf just runs past the end until it hits the end of the underlying string in text_typed.
You'd have to use al_ustr_to_buffer if you wanted a 'stand-alone' C string, which makes the whole substring thing a bit pointless maybe.
Obviously if you stick to ustr functions then the string made by al_ref_ustr would work perfectly.
That helped. I was using printf for troubleshooting in the original code, however. In the end, I wrote a very different code for external reasons though.
Thanks anyway!