[Win32utils-devel] Wide strings and LPCTSTR types

win32utils-devel at rubyforge.org win32utils-devel at rubyforge.org
Thu Feb 26 16:00:23 EST 2004


> -----Original Message-----
> From: win32utils-devel-bounces at rubyforge.org 
> [mailto:win32utils-devel-bounces at rubyforge.org] On Behalf Of 
> win32utils-devel at rubyforge.org
> Sent: Wednesday, February 25, 2004 5:07 PM
> To: win32utils-devel at rubyforge.org
> Subject: Re:[Win32utils-devel] Wide strings and LPCTSTR types
<snip>
> Would you try mbstowcs like following?
> 
>     nLen = strlen(szText) + 1;
>     wszBuffer = malloc(nLen) * sizeof(WCHAR);
>     mbstowcs(wszBuffer, szText, nLen);

I tried this:

LPCTSTR AllocWideLPCString(VALUE rbString){
   char* szText = STR2CSTR(rbString);
   int nLen = (strlen(szText) + 1) * sizeof(LPCTSTR);
   LPCTSTR wszBuffer = (LPCTSTR)malloc(nLen);
   mbstowcs(wszBuffer, szText, nLen);
   return wszBuffer;
}

It still didn't work.

Dan



More information about the win32utils-devel mailing list