str_printf and Unicode?

Posted By: Superku

str_printf and Unicode? - 10/25/16 05:33

The beta features page says:
Quote:
The str_printf function now also supports Unicode.

Does it really? When I use str_printf on a Unicode string it just results in a scrambled mess of chinese/ whatever symbols. Is there something I am missing?
(As a workaround I can obviously call str_printf on a regular ASCII string, then copy that into the Unicode string in question.)


EDIT: Oh and what are the (undocumented) (Unicode) STRING flags?
I assume (1<<3) and (1<<7) are something like "string is modified", and (1<<6) is the "string is in Unicode" bit? And where is the short array saved, in a different internal buffer?
I have a text object and a string which I use to draw most of my UI stuff with draw_obj. Can I reset the text's string's Unicode bit manually (let's say before the next str_cpy with an ASCII source string) or would that lead to a memory leak?
(Flag 6 is still set after str_printf but you can draw the text with the chars pointer - which you shouldn't be able to with Unicode, right?)
Posted By: jcl

Re: str_printf and Unicode? - 10/31/16 12:48

str_printf indeed supports no Unicode yet. That beta feature was a little premature - the next version will support Unicode for str_printf, but not the current version.

Here are all flag definitions for strings:

const long STRF_CHANGED = (1<<0); // String was modified
const long STRF_NOWIO = (1<<1); // String is edited with INKEY
const long STRF_SYS = (1<<2); // system string / don't deallocate
const long STRF_NCRLF = (1<<3); // Crlf Count yet to be done
const long STRF_NSAVE = (1<<5); // Don't save this string
const long STRF_UNICODE = (1<<6); // String contains 16-bit characters
const long STRF_NOHASH = (1<<7); // Ignore '#'



Posted By: Superku

Re: str_printf and Unicode? - 10/31/16 16:15

Ok, thanks for the response and information!
© 2024 lite-C Forums