Hi, how can I pass a variable to uni$?
for example I would like to do something like:
strBuffer db "Passme",0
str$(addr Passme)
instead of:
str$("Passme")
Thank you
Quote from: clip32 on November 05, 2009, 04:33:47 AM
Hi, how can I pass a variable to uni$?
str$(addr Passme)
Your question is pretty unclear. What do you mean with
uni$: Unicode-string?? str$("passme") doesn't make sense, in contrast to str$(123)...
This makes sense:
myval dd 123
...
str$(myval)
But that is not what you want, it seems. Hint: Try MasmBasic (http://www.masm32.com/board/index.php?topic=12460), it even has a wChr$("Test"), in case you really need Unicode.
Cluip,
the "str$()" macro is a conversion from a number to a text string. You pass an actual string by its ADDRESS. If its in the .DATA section use OFFSET, if its from dynamic code use the pointer that is returned from various functions.
clip32,
The uni$ macro defines a Unicode string in the data section, at assembly time. If you need to convert an existing character string to a Unicode string, it will need to be done at run time. One possibility would be to use the MultiByteToWideChar function (http://msdn.microsoft.com/en-us/library/dd319072(VS.85).aspx).
oh silly me, i mean't uni$ not str$.
thank you for the answers, the MultiByteToWideChar function did it.
regards everyone,
Quote from: clip32 on November 06, 2009, 04:14:10 AM
thank you for the answers, the MultiByteToWideChar function did it.
wChr$() uses a simpler lodsb, stosw algo, but it also does the job.
Quoteinvoke MessageBoxW, 0, wChr$("Hello Masm32"), wChr$("Unicode is simple:"), MB_OK
Open "O", #1, "Wide.txt"
wPrint #1, wChr$("This is Unicode", 13, 10)
Close