on Sep 11th, 2011, 6:29pm, Nick wrote:How do I 'assign' a buffer of such unicode text in such a way that I define the length of the 'string' to be passed rather than using the typical X$ type variable? |
|
The problem isn't that the string is held in a variable (like X$) since string variables can contain NULs (zero bytes) quite happily. Rather, it's because you are using the $$ operator, which assumes the first NUL terminates the string.
So one solution is not to use $$ at all, but simply to pass a regular string variable to the editor thus:
Code:SYS "SetWindowTextW", hRichEdit%, X$
For this to work you must ensure that the variable X$ contains at least one terminating NUL at the end (since BASIC adds only one extra NUL, and UTF-16 requires a termination of two NULs).
Another approach would be to pass the address of a memory buffer containing the string (which would then need both terminating NULs to be explicitly stored):
Code:SYS "SetWindowTextW", hRichEdit%, A%
Richard.