Is possible, what do you thing about this function.
Can i use hb_retclenAdopt instead of hb_retclenAdoptRaw in this case ?
or is necessary ?
HB_FUNC( UTF8TOWIDE ) // ( cAnsiStr ) -> cWideStr
{
char *cString = hb_parc( 1 );
if( cString )
{
BSTR wString = hb_oleUTF8ToWide( cString );
if( wString )
{
hb_retclenAdoptRaw( (char *) wString, SysStringLen( wString ) );
return;
}
}
hb_ret();
return;
}
//---------------------------------------------------------------------------//
HB_EXPORT LPWSTR hb_oleUTF8ToWide( LPSTR cString )
{
int nConvertedLen = MultiByteToWideChar( CP_UTF8, 0, cString, -1, NULL, 0 );
if( nConvertedLen )
{
LPWSTR wString = (LPWSTR) hb_xgrab( nConvertedLen * 3 );
if( MultiByteToWideChar( CP_UTF8, 0, cString, -1, wString, nConvertedLen
) )
{
return (LPWSTR) wString;
}
else
{
hb_xfree( wString );
}
}
return NULL;
}
Best regards,
Miguel Angel Marchuet
Przemyslaw Czerpak escribió:
On Tue, 21 Oct 2008, Miguel Angel Marchuet wrote:
Hi Miguel,
2008-10-21 13:17 UTC+0100 Miguel Angel Marchuet <[EMAIL PROTECTED]>
* contrib/xhb/hbcompat.h
+ added compatibilities.
Thank you for modifications but this one:
#define hb_retclenAdoptRaw( szText, ulLen ) hb_retclen_buffer( (szText),
(ulLen) )
can be source of serious problems.
hb_retclen_buffer() always sets '\0' at the end of passed string and
hb_retclenAdoptRaw() in xHarbour doesn't. I strongly preffer that
programmers which create common code for Harbour and xHarbour make
it ready for such situations and in such case then can simply use
hb_retclenAdopt()/hb_retclen_buffer() instead of hb_retclenAdoptRaw()
so such #define is not be necessary at all.
It only pacifies C compiler errors hiding the potential problem and
allow to create buggy binaries.
It should be reverted.
best regards,
Przemek
_______________________________________________
Harbour mailing list
Harbour@harbour-project.org
http://lists.harbour-project.org/mailman/listinfo/harbour
__________ Informaci�n de ESET NOD32 Antivirus, versi�n de la base de firmas de
virus 3542 (20081021) __________
ESET NOD32 Antivirus ha comprobado este mensaje.
http://www.eset.com
_______________________________________________
Harbour mailing list
Harbour@harbour-project.org
http://lists.harbour-project.org/mailman/listinfo/harbour