To create an ANSI string:
str7 db 'c:\\a.exe', 0
To create a UTF-16 string:
str8 db 'c', 0, ':', 0, '\', 0, '\', 0, 'a', 0, '.', 0, 'e', 0, 'x', 0, 'e', 0, 0, 0
Do I have to hand-roll my own UTF-16 strings? or is there some easier way?
you can use the macros WSTR and uni$() that can be found in \masm32\macros\ucmacros.asm.
(there are problems when using these macros in combination with the rv() and fn macros)
One option for "real" Unicode is resource strings - see LoadStringW. MasmBasic uses them for its wRes$(id) macro.
Mean you convert from ansii to Unicode?
If correct try this
invoke Ansi2Unicode,addr str1,addr obuf
invoke MessageBoxW,0,addr obuf,addr obuf,MB_OK ;unicode MessageBox
invoke Unicode2Ansi,addr obuf,addr obuf2
invoke MessageBox,0,addr obuf2,addr ascii,MB_OK
invoke ExitProcess,0
Ansi2Unicode proc iString,ouptbuf
invoke lstrlen,iString
invoke MultiByteToWideChar,CP_ACP,0,iString,-1,ouptbuf,eax
ret
Ansi2Unicode endp
Unicode2Ansi proc iString,ouptbuf
invoke lstrlen,ouptbuf
invoke WideCharToMultiByte,CP_ACP,0,iString,-1,ouptbuf,eax,0,0
invoke WideCharToMultiByte,CP_ACP,0,iString,-1,ouptbuf,eax,0,0
ret
Unicode2Ansi endp
this should work - haven't tried it - notice "dw" instead of "db"
str8 dw 'c',':','\','\','a','.','e','x','e',0
if the type is a problem...
str8 label byte
dw 'c',':','\','\','a','.','e','x','e',0
The Microsoft "approved" method of unicode strings is to store them in the resource section in a string table. The masm32 macros go part of the way to make them easier to use but they have limitations due to the pre-processor limitations.