Files
harbour-core/harbour/include/hbwinuni.h
Przemyslaw Czerpak cb65540d4e 2009-12-11 20:42 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/src/vm/strapi.c
  * harbour/include/hbapistr.h
    + added new functions to operate on Harbour wide character strings:
         ULONG hb_wstrlen( const HB_WCHAR * szText );
         HB_WCHAR * hb_wstrdup( const HB_WCHAR * szText );
         HB_WCHAR * hb_wstrndup( const HB_WCHAR * szText, ULONG ulLen );
         int hb_wstrcmp( const HB_WCHAR * s1, const HB_WCHAR * s2 );
         int hb_wstrncmp( const HB_WCHAR * s1,
                          const HB_WCHAR * s2, ULONG count );
    + added new functions to convert NULL pointers to empty strings:
         const char * hb_strnull( const char * str );
         const HB_WCHAR * hb_wstrnull( const HB_WCHAR * str );
    + added new functions to convert string buffer returned by Harbour
      string functions to writable state:
         char * hb_strunshare( void ** phStr,
                               const char * pStr, ULONG ulLen );
         HB_WCHAR * hb_wstrunshare( void ** phStr,
                                    const HB_WCHAR * pStr, ULONG ulLen );
  * harbour/include/hbwinuni.h
    ! fixed HB_PARSTRDEF() to return empty string instead of NULL
    ! fixed HB_ARRAYSETSTR() to accept NULL as string parameter
2009-12-11 19:42:40 +00:00

93 lines
4.2 KiB
C

/*
* $Id$
*/
/*
* Harbour Project source code:
* Windows UNICODE helper macros
*
* Copyright 2009 Viktor Szakats (harbour.01 syenar.hu)
* www - http://www.harbour-project.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this software; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/).
*
* As a special exception, the Harbour Project gives permission for
* additional uses of the text contained in its release of Harbour.
*
* The exception is that, if you link the Harbour libraries with other
* files to produce an executable, this does not by itself cause the
* resulting executable to be covered by the GNU General Public License.
* Your use of that executable is in no way restricted on account of
* linking the Harbour library code into it.
*
* This exception does not however invalidate any other reasons why
* the executable file might be covered by the GNU General Public License.
*
* This exception applies only to the code released by the Harbour
* Project under the name Harbour. If you copy code from other
* Harbour Project or Free Software Foundation releases into a copy of
* Harbour, as the General Public License permits, the exception does
* not apply to the code that you add in this way. To avoid misleading
* anyone as to the status of such modified files, you must delete
* this exception notice from them.
*
* If you write modifications of your own for Harbour, it is your choice
* whether to permit this exception to apply to your modifications.
* If you do not wish that, delete this exception notice.
*
*/
#ifndef HB_WINUNI_H_
#define HB_WINUNI_H_
#include "hbapistr.h"
#if defined( HB_OS_WIN )
#include "hbset.h"
#if defined( UNICODE )
#define HB_PARSTR( n, h, len ) hb_parstr_u16( n, HB_CDP_ENDIAN_NATIVE, h, len )
#define HB_PARSTRDEF( n, h, len ) hb_wstrnull( hb_parstr_u16( n, HB_CDP_ENDIAN_NATIVE, h, len ) )
#define HB_RETSTR( str ) hb_retstr_u16( HB_CDP_ENDIAN_NATIVE, ( const HB_WCHAR * ) ( str ) )
#define HB_RETSTRLEN( str, len ) hb_retstrlen_u16( HB_CDP_ENDIAN_NATIVE, ( const HB_WCHAR * ) ( str ), len )
#define HB_STORSTR( str, n ) hb_storstr_u16( HB_CDP_ENDIAN_NATIVE, ( const HB_WCHAR * ) ( str ), n )
#define HB_STORSTRLEN( str, len, n ) hb_storstrlen_u16( HB_CDP_ENDIAN_NATIVE, ( const HB_WCHAR * ) ( str ), len, n )
#define HB_ARRAYSETSTR( arr, n, str ) \
hb_itemPutStrLenU16( hb_arrayGetItemPtr( arr, n ), \
HB_CDP_ENDIAN_NATIVE, str, hb_wstrlen( hb_wstrnull( str ) ) )
#define HB_ARRAYSETSTRLEN( arr, n, str, len ) \
hb_itemPutStrLenU16( hb_arrayGetItemPtr( arr, n ), \
HB_CDP_ENDIAN_NATIVE, str, len )
#else
#define HB_PARSTR( n, h, len ) hb_parstr( n, hb_setGetOSCP(), h, len )
#define HB_PARSTRDEF( n, h, len ) hb_strnull( hb_parstr( n, hb_setGetOSCP(), h, len ) )
#define HB_RETSTR( str ) hb_retstr( hb_setGetOSCP(), str )
#define HB_RETSTRLEN( str, len ) hb_retstrlen( hb_setGetOSCP(), str, len )
#define HB_STORSTR( str, n ) hb_storstr( hb_setGetOSCP(), str, n )
#define HB_STORSTRLEN( str, len, n ) hb_storstrlen( hb_setGetOSCP(), str, len, n )
#define HB_ARRAYSETSTR( arr, n, str ) \
hb_itemPutStrLen( hb_arrayGetItemPtr( arr, n ), \
hb_setGetOSCP(), str, strlen( hb_strnull( str ) ) )
#define HB_ARRAYSETSTRLEN( arr, n, str, len ) \
hb_itemPutStrLen( hb_arrayGetItemPtr( arr, n ), \
hb_setGetOSCP(), str, len )
#endif
#endif /* HB_OS_WIN */
#endif /* HB_WINUNI_H_ */