On Tue, 21 Oct 2008, Miguel Angel Marchuet wrote:

Hi Miguel,

> Is possible, what do you thing about this function.
> Can i use hb_retclenAdopt instead of hb_retclenAdoptRaw in this case ?
> or is necessary ?

You have to and in this case you should 1-st fix the conversion code
or it may cause unexpected results like GPF.

Below is corrected version (not tested just written).

best regards,
Przemek


HB_FUNC( UTF8TOWIDE )  // ( cAnsiStr ) -> cWideStr
{
   char *cString = hb_parc( 1 );

   if( cString )
   {
      DWORD length;
      wchar_t * wString;

      length = MultiByteToWideChar( CP_UTF8, 0, cString, -1, NULL, 0 );
      wString = ( wchar_t * ) hb_xgrab( ( length + 1 ) * sizeof( wchar_t ) );
      MultiByteToWideChar( CP_UTF8, 0, cString, -1, wString, length + 1 );
      hb_retclen_buffer( ( char * ) wString, length * sizeof( wchar_t ) );
   }
}
_______________________________________________
Harbour mailing list
Harbour@harbour-project.org
http://lists.harbour-project.org/mailman/listinfo/harbour

Reply via email to