[Win32utils-devel] Wide strings and LPCTSTR types

win32utils-devel at rubyforge.org win32utils-devel at rubyforge.org
Fri Feb 27 08:53:10 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);
should be
     int nLen = (strlen(szText) + 1) * sizeof(WCHAR);

>    LPCTSTR wszBuffer = (LPCTSTR)malloc(nLen);
>    mbstowcs(wszBuffer, szText, nLen);
>    return wszBuffer;
> }
> 
> It still didn't work.
> 
> Dan

Regards,

Park Heesob



--MIME Multi-part separator--



More information about the win32utils-devel mailing list