Hi,

>    I'm working on a related issue which is trying to get 16bit Unicode
> strings from L##"some text", or more precisely from the __TEXT() macro.

I wasn't going to look at this just yet, but I just did anyway.

Attached is a sample of how I expect we'll end up doing it, You need to
compile with "-fwritable-strings" though. Its not very clever, but it doesn't
leak memory like other approaches could.

We are going to need a conditional for whether Winelib is using libc or
mscvrt in the headers soon (this code should be wrapped with it if integrated
into Wine).

Cheers,
Jon

--------
#include <stdio.h>
#include <wchar.h>

inline unsigned short* wine_make_unicode_str(wchar_t * str)
{
  if (str)
  {
    unsigned short * save = (unsigned short*)str, * win_str = save;
    if (*str && 0xffff0000)
    while(*str != L'\0')
      *win_str++ = *str++ & 0xffff;
    *win_str = L'\0' & 0xff;
    return save;
  }
  return NULL;
}

#define __TEXT(x) wine_make_unicode_str((wchar_t *)L##x)

int main()
{
  unsigned short* x = __TEXT("TEXT");
  wchar_t * t = L"TEXT";

  fprintf(stdout,"Uncode (libc): %3d %3d %3d %3d% d\n",
          t[0], t[1],t[2],t[3],t[4]);
  fprintf(stdout,"WCHAR  (wine): %3d %3d %3d %3d %d\n",
          x[0], x[1], x[2], x[3], x[4]);
  return 1;
}

--
"May their negative actions ripen upon me. And may all my virtues ripen upon
them."
"If it could be talked about, everybody would have told their brother."
[EMAIL PROTECTED] , [EMAIL PROTECTED]


Reply via email to