I want to declare unicode string in MASM. How should I do it?

SomeString1 db 'S',0,'o',0,'m',0,'e',0,0 is rather annoying to type.

SomeString2 dw 'S','o','m','e',0 is better but still annoying.

SomeString3 dw 'Some',0 doesn't work (Wneither does WCHAR since it's an alias for dw AFAIK).

So, I tried to make some macro to deal with it but MASM still reports errors! Any solution?
Posted on 2002-03-25 12:25:36 by marcinbu
There is two ways to attack this prob:

The first is to do this dynamically with API's, and convert normal strings to Unicode strings. The API to think about is:
int MultiByteToWideChar( 

UINT CodePage, // code page (use CP_ACP)
DWORD dwFlags, // character-type options
LPCSTR lpMultiByteStr, // address of string to map
int cchMultiByte, // number of bytes in string
LPWSTR lpWideCharStr, // address of wide-character buffer
int cchWideChar // size of buffer
);


Ernie has made some macro's on the COM section to simplify this API a bit more: Look Here

If not, there is a static way, that your getting at. Im not certain (as im at a school computer) but i believe Ernie also did some work on this macro too, its called L (( found in the COM section of the MASM32 package )).

Here is some same code i dug up from searching the board:


include \masm32\COM\include\L.inc

.data
toolbars wchar L(<CommandBars\0> )
adds wchar L(<Item\0> )
mybarr wchar L(<Standard\0> )


This builds relatively short Unicode strings, wher the null is symbolized as "\0". I recomend looking over this include to learn other switches (such as line returns). Its also limited to 512 bytes (or so) of string text to convert due to MASM's restrictions on text/line processing when compiling.

This should get you goin quite well,
Hope it helps.
:alright:
NaN
Posted on 2002-03-25 14:37:57 by NaN
Thanx! This is exactly what I've been looking for :alright:
Posted on 2002-03-25 16:24:24 by marcinbu