How to convert C++--> CPP ?

Post Reply
ShumingWang
Posts: 454
Joined: Sun Oct 30, 2005 6:37 am
Location: Guangzhou(Canton),China

How to convert C++--> CPP ?

Post 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
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post 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 ); 
} 
regards, saludos

Antonio Linares
www.fivetechsoft.com
ShumingWang
Posts: 454
Joined: Sun Oct 30, 2005 6:37 am
Location: Guangzhou(Canton),China

Post by ShumingWang »

Antonio,
Thank you very much!
Shuming Wang
Post Reply