Page 1 of 1

memoryWriteUString ?

Posted: Wed Oct 28, 2009 2:55 am
by Zilvermoon
Hi just wanted to know if there is a plan to support writing an U string to memory ?

Currently it looks like there are no way to write a string to memory at all ...

memoryWriteString
memoryWriteUString
memoryWriteStringPtr
memoryWriteUStringPtr

none of these are available, so what is my option convert a string and write it with "memoryWriteByte"?
or you got any other suggestions?

Zilvermoon

Re: memoryWriteUString ?

Posted: Wed Oct 28, 2009 9:29 am
by Administrator
The problem with string writing to memory comes when you don't know the buffer size. If you overstep the boundary, you're likely to crash the program. Unicode is even more of a pain because there are so many different types of unicode that follow different rules. Sometimes characters are 2 bytes, sometimes 4 bytes, or even 1, 2, or 4 within the same string. Sometimes embedded zeros work, and sometimes they don't. How you should write the string depends entirely on exactly how unicode was implemented within that program. There is also the problem that unicode isn't supported by Lua.

About the best thing that can be done is to write the bytes one at a time and make sure you are using the correct byte widths and terminator.