Page 1 of 1

How to convert C++--> CPP ?

Posted: Fri Nov 16, 2007 5:14 am
by ShumingWang
Hi

void BIG52GBK(char *szBuf)
{
  if(!strcmp(szBuf, ""))
   return;
  int nStrLen = strlen(szBuf);
  wchar_t *pws = new wchar_t[nStrLen + 1];
  try
  {
   int nReturn = MultiByteToWideChar(950, 0, szBuf, nStrLen, pws, nStrLen + 1);
   BOOL bValue = false;
   nReturn = WideCharToMultiByte(936, 0, pws, nReturn, szBuf, nStrLen + 1, "?", &bValue);
   szBuf[nReturn] = 0;
  }
  __finally
  {
   delete[] pws;
  }
}

harbour request : HB_FUNC(BIG52GBK)

Regards

Shuming Wang

Posted: Fri Nov 16, 2007 8:34 am
by Antonio Linares

Code: Select all

#include <hbapi.h>
#include <windows.h>

HB_FUNC( BIG52GBK )
{
   char * szBuf = hb_parc( 1 );
   int nStrLen = strlen( szBuf ); 
   LPWSTR pws = ( LPWSTR ) hb_xgrab( ( sStrLen + 1 ) * 2 );
   int nReturn = MultiByteToWideChar( 950, 0, szBuf, nStrLen, pws,          
                                                        nStrLen + 1); 
   BOOL bValue = FALSE;
 
   nReturn = WideCharToMultiByte( 936, 0, pws, nReturn, szBuf, 
                                                    nStrLen + 1, "?", &bValue); 
   szBuf[ nReturn ] = 0; 
   hb_retclen( ( char * ) pws, nReturn );
   hb_xfree( pws ); 
} 

Posted: Fri Nov 16, 2007 11:56 am
by ShumingWang
Antonio,
Thank you very much!
Shuming Wang