2012-09-17 14:03 UTC+0200 Viktor Szakats (harbour syenar.net)

+ contrib/hbwin/oemansi.c
  * contrib/hbwin/hbwin.hbp
  * contrib/hbwin/hbwin.hbx
    + added WIN_OEMTOANSI() and WIN_ANSITOOEM(). These are
      compatible with current core HB_OEMTOANSI()/HB_ANSITOOEM()
      Usage of them is not recommended.

  * contrib/hbxpp/oemansix.c
    * CONVTOANSICP()/CONVTOOEMCP() changed to use local
      implementation instead of relying on now deprecated
      core OEM/ANSI functions

  * src/rtl/oemansi.c
    * HB_OEMTOANSI()/HB_ANSITOOEM() Windows-specific functions
      deprecated with HB_LEGACY_LEVEL4 (meaning they will
      disappear after next stable release). Either avoid
      these calls completely (recommended) or change them to
      hbwin or hbxbp equivalents.

  * contrib/hbtip/thtml.prg
  * contrib/hbtip/hbtip.hbx
    * deprecated HtmlToAnsi(), HtmlToOem(), AnsiToHtml(), OemToHtml()
      functions with HB_LEGACY_LEVEL4.
    + added TIP_STRTOHTML(), TIP_HTMLTOSTR() functions which cover
      major above functionality, but in a portable and CP agnostic
      way. Code untested, if you need it, test it and provide feedback
      and/or fix.
This commit is contained in:
Viktor Szakats
2012-09-17 12:11:23 +00:00
parent 349ea7f5e7
commit 3d08bef043
8 changed files with 397 additions and 12 deletions

View File

@@ -16,6 +16,35 @@
The license applies to all entries newer than 2009-04-28.
*/
2012-09-17 14:03 UTC+0200 Viktor Szakats (harbour syenar.net)
+ contrib/hbwin/oemansi.c
* contrib/hbwin/hbwin.hbp
* contrib/hbwin/hbwin.hbx
+ added WIN_OEMTOANSI() and WIN_ANSITOOEM(). These are
compatible with current core HB_OEMTOANSI()/HB_ANSITOOEM()
Usage of them is not recommended.
* contrib/hbxpp/oemansix.c
* CONVTOANSICP()/CONVTOOEMCP() changed to use local
implementation instead of relying on now deprecated
core OEM/ANSI functions
* src/rtl/oemansi.c
* HB_OEMTOANSI()/HB_ANSITOOEM() Windows-specific functions
deprecated with HB_LEGACY_LEVEL4 (meaning they will
disappear after next stable release). Either avoid
these calls completely (recommended) or change them to
hbwin or hbxbp equivalents.
* contrib/hbtip/thtml.prg
* contrib/hbtip/hbtip.hbx
* deprecated HtmlToAnsi(), HtmlToOem(), AnsiToHtml(), OemToHtml()
functions with HB_LEGACY_LEVEL4.
+ added TIP_STRTOHTML(), TIP_HTMLTOSTR() functions which cover
major above functionality, but in a portable and CP agnostic
way. Code untested, if you need it, test it and provide feedback
and/or fix.
2012-09-17 12:23 UTC+0200 Przemyslaw Czerpak (druzus/at/poczta.onet.pl)
* harbour/contrib/hbwin/hbwinole.h
* harbour/contrib/hbwin/olecore.c
@@ -42,25 +71,25 @@
integers.
Warning! this modification is not backward compatible. If some
needs previous behavior then he should change create conversion
functions.
functions. [INCOMPATIBLE]
; Please test it. I made all this modifications in Linux without
any real tests.
2012-09-16 16:47 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com)
* contrib/gtwvg/gtwvg.c
+ hb_gtInfo( HB_GTI_SETPOSANDSIZE ) returns the existing position
+ hb_gtInfo( HB_GTI_SETPOSANDSIZE ) returns the existing position
and size: { nX, nY, nWidth, nHeight } in pixels.
* contrib/hbqt/hbmk2_qt.hb
+ someObject:setHtml( cHtmlCode ) now reads the html text correctly
off a .ui file. This makes possible to draft html pages in
Qt creator itself and assigned to an relevant object, like
+ someObject:setHtml( cHtmlCode ) now reads the html text correctly
off a .ui file. This makes possible to draft html pages in
Qt creator itself and assigned to an relevant object, like
QLabel, QTextEdit, QTextBrowser, etc.
2012-09-14 21:07 UTC+0200 Firstname Lastname (me domain.net)
* utils/hbmk2/hbmk2.prg
* hbmk_OutStdRaw() and hb_OutErrRaw() hbmk2 plugin
API functions parameter list modified so that now they
* hbmk_OutStdRaw() and hb_OutErrRaw() hbmk2 plugin
API functions parameter list modified so that now they
expect hbmk context as first parameter.
INCOMPATIBLE.
! made sure that hbmk_OutStdRaw() and hbmk_OutErrRaw()

View File

@@ -64,11 +64,13 @@ DYNAMIC TIP_GETENCODER
DYNAMIC TIP_GETNAMEEMAIL
DYNAMIC TIP_GETRAWEMAIL
DYNAMIC TIP_HTMLSPECIALCHARS
DYNAMIC TIP_HTMLTOSTR
DYNAMIC TIP_JSONSPECIALCHARS
DYNAMIC TIP_MIMETYPE
DYNAMIC TIP_QPDECODE
DYNAMIC TIP_QPENCODE
DYNAMIC TIP_SSL
DYNAMIC TIP_STRTOHTML
DYNAMIC TIP_TIMESTAMP
DYNAMIC TIP_URLDECODE
DYNAMIC TIP_URLENCODE

View File

@@ -93,6 +93,8 @@
THREAD STATIC t_aHtmlAttr // data for HTML attributes
THREAD STATIC t_hTagTypes // data for HTML tags
THREAD STATIC t_cHtmlCP := ""
THREAD STATIC t_aHtmlEntities // HTML character entities
THREAD STATIC t_aHtmlAnsiEntities // HTML character entities (ANSI character set)
THREAD STATIC t_lInit := .F. // initilization flag for HTML data
@@ -4515,6 +4517,8 @@ STATIC FUNCTION THtmlAttr_XMP()
t_aHtmlAttr[ HTML_ATTR_UNKNOWN ] ;
}
#ifdef HB_LEGACY_LEVEL4
// Converts an HTML formatted text string to the ANSI character set
FUNCTION HtmlToAnsi( cHtmlText )
@@ -4615,7 +4619,7 @@ FUNCTION OemToHtml( cOemText )
// This function returs the HTML character entities that are exchangeable between ANSI and OEM character sets
STATIC PROCEDURE _Init_Html_AnsiCharacterEntities
STATIC PROCEDURE _Init_Html_AnsiCharacterEntities()
t_aHtmlAnsiEntities := ;
{ ;
@@ -4698,3 +4702,175 @@ STATIC PROCEDURE _Init_Html_AnsiCharacterEntities
}
RETURN
#endif
// Converts an HTML formatted text string to the ANSI character set
FUNCTION tip_HtmlToStr( cHtmlText )
LOCAL aEntity
_Init_Html_CharacterEntities()
FOR EACH aEntity IN t_aHtmlEntities
IF aEntity[ 2 ] $ cHtmlText
cHtmlText := StrTran( cHtmlText, aEntity[ 2 ], aEntity[ 1 ] )
ENDIF
NEXT
IF " " $ cHtmlText
cHtmlText := StrTran( cHtmlText, " ", " " )
ENDIF
RETURN cHtmlText
// Inserts HTML character entities into an ANSI text string
FUNCTION tip_StrToHtml( cAnsiText )
LOCAL cHtmlText := ""
LOCAL parser := P_PARSER( cAnsiText )
LOCAL nStart := 1
LOCAL aEntity, cEntity, cText, cChr, nEnd
_Init_Html_CharacterEntities()
// Convert to Html but ignore all html character entities
DO WHILE P_SEEK( parser, "&" ) > 0
nEnd := parser:p_pos
cText := SubStr( parser:p_str, nStart, nEnd - nStart )
DO WHILE ! ( ( cChr := P_NEXT( parser ) ) $ "; " ) .AND. ! Empty( cChr ) .AND. parser:p_pos != 0
ENDDO
SWITCH cChr
CASE ";"
// HTML character entity found
nStart := nEnd
nEnd := parser:p_pos + 1
cEntity := SubStr( parser:p_str, nStart, nEnd - nStart )
parser:p_end := parser:p_pos
parser:p_pos ++
EXIT
CASE " "
// "&" character found
cHtmlText += cText
nStart := nEnd
nEnd := parser:p_pos + 1
cText := SubStr( parser:p_str, nStart, nEnd - nStart )
nStart := nEnd
cHtmlText += "&" + SubStr( cText, 2 )
LOOP
OTHERWISE
cEntity := NIL
ENDSWITCH
IF cEntity != NIL
nStart := parser:p_pos
FOR EACH aEntity IN t_aHtmlEntities
IF aEntity[ 1 ] $ cText
cText := StrTran( cText, aEntity[ 1 ], aEntity[ 2 ] )
ENDIF
NEXT
cHtmlText += cText + cEntity
ENDIF
ENDDO
cText := SubStr( parser:p_str, nStart )
FOR EACH aEntity IN t_aHtmlEntities
IF aEntity[ 1 ] $ cText
cText := StrTran( cText, aEntity[ 1 ], aEntity[ 2 ] )
ENDIF
NEXT
cHtmlText += cText
RETURN cHtmlText
STATIC PROCEDURE _Init_Html_CharacterEntities()
IF t_aHtmlEntities == NIL .OR. !( t_cHtmlCP == hb_cdpSelect() )
t_cHtmlCP := hb_cdpSelect()
t_aHtmlEntities := ;
{ ;
{ hb_UTF8ToStr( "&" ), "&" }, ; // ampersand
{ hb_UTF8ToStr( "<" ), "&lt;" }, ; // less-than sign
{ hb_UTF8ToStr( ">" ), "&gt;" }, ; // greater-than sign
{ hb_UTF8ToStr( "¢" ), "&cent;" }, ; // cent sign
{ hb_UTF8ToStr( "£" ), "&pound;" }, ; // pound sign
{ hb_UTF8ToStr( "¥" ), "&yen;" }, ; // yen sign
{ hb_UTF8ToStr( "¦" ), "&brvbar;" }, ; // broken bar
{ hb_UTF8ToStr( "§" ), "&sect;" }, ; // section sign
{ hb_UTF8ToStr( "©" ), "&copy;" }, ; // copyright sign
{ hb_UTF8ToStr( "®" ), "&reg;" }, ; // registered sign
{ hb_UTF8ToStr( "°" ), "&deg;" }, ; // degree sign
{ hb_UTF8ToStr( "¿" ), "&iquest;" }, ; // inverted question mark
{ hb_UTF8ToStr( "À" ), "&Agrave;" }, ; // Latin capital letter a with grave
{ hb_UTF8ToStr( "Á" ), "&Aacute;" }, ; // Latin capital letter a with acute
{ hb_UTF8ToStr( "Â" ), "&Acirc;" }, ; // Latin capital letter a with circumflex
{ hb_UTF8ToStr( "Ã" ), "&Atilde;" }, ; // Latin capital letter a with tilde
{ hb_UTF8ToStr( "Ä" ), "&Auml;" }, ; // Latin capital letter a with diaeresis
{ hb_UTF8ToStr( "Å" ), "&Aring;" }, ; // Latin capital letter a with ring above
{ hb_UTF8ToStr( "Æ" ), "&AElig;" }, ; // Latin capital letter ae
{ hb_UTF8ToStr( "Ç" ), "&Ccedil;" }, ; // Latin capital letter c with cedilla
{ hb_UTF8ToStr( "È" ), "&Egrave;" }, ; // Latin capital letter e with grave
{ hb_UTF8ToStr( "É" ), "&Eacute;" }, ; // Latin capital letter e with acute
{ hb_UTF8ToStr( "Ê" ), "&Ecirc;" }, ; // Latin capital letter e with circumflex
{ hb_UTF8ToStr( "Ë" ), "&Euml;" }, ; // Latin capital letter e with diaeresis
{ hb_UTF8ToStr( "Ì" ), "&Igrave;" }, ; // Latin capital letter i with grave
{ hb_UTF8ToStr( "Í" ), "&Iacute;" }, ; // Latin capital letter i with acute
{ hb_UTF8ToStr( "Î" ), "&Icirc;" }, ; // Latin capital letter i with circumflex
{ hb_UTF8ToStr( "Ï" ), "&Iuml;" }, ; // Latin capital letter i with diaeresis
{ hb_UTF8ToStr( "Ð" ), "&ETH;" }, ; // Latin capital letter eth
{ hb_UTF8ToStr( "Ñ" ), "&Ntilde;" }, ; // Latin capital letter n with tilde
{ hb_UTF8ToStr( "Ò" ), "&Ograve;" }, ; // Latin capital letter o with grave
{ hb_UTF8ToStr( "Ó" ), "&Oacute;" }, ; // Latin capital letter o with acute
{ hb_UTF8ToStr( "Ô" ), "&Ocirc;" }, ; // Latin capital letter o with circumflex
{ hb_UTF8ToStr( "Õ" ), "&Otilde;" }, ; // Latin capital letter o with tilde
{ hb_UTF8ToStr( "Ö" ), "&Ouml;" }, ; // Latin capital letter o with diaeresis
{ hb_UTF8ToStr( "Ø" ), "&Oslash;" }, ; // Latin capital letter o with stroke
{ hb_UTF8ToStr( "Ù" ), "&Ugrave;" }, ; // Latin capital letter u with grave
{ hb_UTF8ToStr( "Ú" ), "&Uacute;" }, ; // Latin capital letter u with acute
{ hb_UTF8ToStr( "Û" ), "&Ucirc;" }, ; // Latin capital letter u with circumflex
{ hb_UTF8ToStr( "Ü" ), "&Uuml;" }, ; // Latin capital letter u with diaeresis
{ hb_UTF8ToStr( "Ý" ), "&Yacute;" }, ; // Latin capital letter y with acute
{ hb_UTF8ToStr( "Þ" ), "&THORN;" }, ; // Latin capital letter thorn
{ hb_UTF8ToStr( "ß" ), "&szlig;" }, ; // Latin small letter sharp s (German Eszett)
{ hb_UTF8ToStr( "à" ), "&agrave;" }, ; // Latin small letter a with grave
{ hb_UTF8ToStr( "á" ), "&aacute;" }, ; // Latin small letter a with acute
{ hb_UTF8ToStr( "â" ), "&acirc;" }, ; // Latin small letter a with circumflex
{ hb_UTF8ToStr( "ã" ), "&atilde;" }, ; // Latin small letter a with tilde
{ hb_UTF8ToStr( "ä" ), "&auml;" }, ; // Latin small letter a with diaeresis
{ hb_UTF8ToStr( "å" ), "&aring;" }, ; // Latin small letter a with ring above
{ hb_UTF8ToStr( "æ" ), "&aelig;" }, ; // Latin lowercase ligature ae
{ hb_UTF8ToStr( "ç" ), "&ccedil;" }, ; // Latin small letter c with cedilla
{ hb_UTF8ToStr( "è" ), "&egrave;" }, ; // Latin small letter e with grave
{ hb_UTF8ToStr( "é" ), "&eacute;" }, ; // Latin small letter e with acute
{ hb_UTF8ToStr( "ê" ), "&ecirc;" }, ; // Latin small letter e with circumflex
{ hb_UTF8ToStr( "ë" ), "&euml;" }, ; // Latin small letter e with diaeresis
{ hb_UTF8ToStr( "ì" ), "&igrave;" }, ; // Latin small letter i with grave
{ hb_UTF8ToStr( "í" ), "&iacute;" }, ; // Latin small letter i with acute
{ hb_UTF8ToStr( "î" ), "&icirc;" }, ; // Latin small letter i with circumflex
{ hb_UTF8ToStr( "ï" ), "&iuml;" }, ; // Latin small letter i with diaeresis
{ hb_UTF8ToStr( "ð" ), "&eth;" }, ; // Latin small letter eth
{ hb_UTF8ToStr( "ñ" ), "&ntilde;" }, ; // Latin small letter n with tilde
{ hb_UTF8ToStr( "ò" ), "&ograve;" }, ; // Latin small letter o with grave
{ hb_UTF8ToStr( "ó" ), "&oacute;" }, ; // Latin small letter o with acute
{ hb_UTF8ToStr( "ô" ), "&ocirc;" }, ; // Latin small letter o with circumflex
{ hb_UTF8ToStr( "õ" ), "&otilde;" }, ; // Latin small letter o with tilde
{ hb_UTF8ToStr( "ö" ), "&ouml;" }, ; // Latin small letter o with diaeresis
{ hb_UTF8ToStr( "ø" ), "&oslash;" }, ; // Latin small letter o with stroke
{ hb_UTF8ToStr( "ù" ), "&ugrave;" }, ; // Latin small letter u with grave
{ hb_UTF8ToStr( "ú" ), "&uacute;" }, ; // Latin small letter u with acute
{ hb_UTF8ToStr( "û" ), "&ucirc;" }, ; // Latin small letter u with circumflex
{ hb_UTF8ToStr( "ü" ), "&uuml;" }, ; // Latin small letter u with diaeresis
{ hb_UTF8ToStr( "ý" ), "&yacute;" }, ; // Latin small letter y with acute
{ hb_UTF8ToStr( "þ" ), "&thorn;" }, ; // Latin small letter thorn
{ hb_UTF8ToStr( "ÿ" ), "&yuml;" }, ; // Latin small letter y with diaeresis
{ hb_UTF8ToStr( "^" ), "&circ;" }, ; // modifier letter circumflex accent
{ hb_UTF8ToStr( "~" ), "&tilde;" } ; // small tilde
}
ENDIF
RETURN

View File

@@ -32,6 +32,7 @@ hbwin.hbx
axcore.c
mapi.c
oemansi.c
olecore.c
oleuuid.c{watcom}
hbolesrv.c

View File

@@ -281,6 +281,7 @@ DYNAMIC WCE_SIMREADPHONEBOOKENTRY
DYNAMIC WCE_SIMWRITEPHONEBOOKENTRY
DYNAMIC WCE_SMSSENDMESSAGE
DYNAMIC WIN_ABORTDOC
DYNAMIC WIN_ANSITOOEM
DYNAMIC WIN_ANSITOWIDE
DYNAMIC WIN_ARC
DYNAMIC WIN_AXGETCONTROL
@@ -339,6 +340,7 @@ DYNAMIC WIN_LOWORD
DYNAMIC WIN_MAPISENDMAIL
DYNAMIC WIN_N2P
DYNAMIC WIN_NCMDSHOW
DYNAMIC WIN_OEMTOANSI
DYNAMIC WIN_OLEAUTO
DYNAMIC WIN_OLEAUTO___ONERROR
DYNAMIC WIN_OLEAUTO___OPINDEX
@@ -427,6 +429,9 @@ DYNAMIC __OLEINVOKEGET
DYNAMIC __OLEINVOKEMETHOD
DYNAMIC __OLEINVOKEPUT
DYNAMIC __OLEISDISP
DYNAMIC __OLEVARIANT
DYNAMIC __OLEVARIANTTYPE
DYNAMIC __OLEVARIANTVALUE
DYNAMIC __WAPI_DEVMODE_GET
DYNAMIC __WAPI_DEVMODE_NEW
DYNAMIC __WAPI_DEVMODE_SET

View File

@@ -0,0 +1,112 @@
/*
* $Id$
*/
/*
* Harbour Project source code:
* OEM <-> ANSI string conversion functions (Windows specific, Xbase++ ext.)
*
* Copyright 1999-2010 Viktor Szakats (harbour syenar.net)
* www - http://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.
*
*/
#include "hbapi.h"
#include "hbapiitm.h"
#include <windows.h>
HB_FUNC( WIN_ANSITOOEM )
{
PHB_ITEM pString = hb_param( 1, HB_IT_STRING );
if( pString )
{
int nLen = ( int ) hb_itemGetCLen( pString );
const char * pszSrc = hb_itemGetCPtr( pString );
int nWideLen = MultiByteToWideChar( CP_ACP, MB_PRECOMPOSED, pszSrc, nLen, NULL, 0 );
LPWSTR pszWide = ( LPWSTR ) hb_xgrab( ( nWideLen + 1 ) * sizeof( wchar_t ) );
char * pszDst;
MultiByteToWideChar( CP_ACP, MB_PRECOMPOSED, pszSrc, nLen, pszWide, nWideLen );
nLen = WideCharToMultiByte( CP_OEMCP, 0, pszWide, nWideLen, NULL, 0, NULL, NULL );
pszDst = ( char * ) hb_xgrab( nLen + 1 );
WideCharToMultiByte( CP_OEMCP, 0, pszWide, nWideLen, pszDst, nLen, NULL, NULL );
hb_xfree( pszWide );
hb_retclen_buffer( pszDst, nLen );
}
else
hb_retc_null();
}
HB_FUNC( WIN_OEMTOANSI )
{
PHB_ITEM pString = hb_param( 1, HB_IT_STRING );
if( pString )
{
int nLen = ( int ) hb_itemGetCLen( pString );
const char * pszSrc = hb_itemGetCPtr( pString );
int nWideLen = MultiByteToWideChar( CP_OEMCP, MB_PRECOMPOSED, pszSrc, nLen, NULL, 0 );
LPWSTR pszWide = ( LPWSTR ) hb_xgrab( ( nWideLen + 1 ) * sizeof( wchar_t ) );
char * pszDst;
MultiByteToWideChar( CP_OEMCP, MB_PRECOMPOSED, pszSrc, nLen, pszWide, nWideLen );
nLen = WideCharToMultiByte( CP_ACP, 0, pszWide, nWideLen, NULL, 0, NULL, NULL );
pszDst = ( char * ) hb_xgrab( nLen + 1 );
WideCharToMultiByte( CP_ACP, 0, pszWide, nWideLen, pszDst, nLen, NULL, NULL );
hb_xfree( pszWide );
hb_retclen_buffer( pszDst, nLen );
}
else
hb_retc_null();
}

View File

@@ -51,16 +51,72 @@
*/
#include "hbapi.h"
#include "hbapiitm.h"
HB_FUNC_EXTERN( HB_ANSITOOEM );
HB_FUNC_EXTERN( HB_OEMTOANSI );
#if defined( HB_OS_WIN )
#include <windows.h>
#endif
HB_FUNC( CONVTOOEMCP )
{
HB_FUNC_EXEC( HB_ANSITOOEM );
PHB_ITEM pString = hb_param( 1, HB_IT_STRING );
if( pString )
#if defined( HB_OS_WIN )
{
int nLen = ( int ) hb_itemGetCLen( pString );
const char * pszSrc = hb_itemGetCPtr( pString );
int nWideLen = MultiByteToWideChar( CP_ACP, MB_PRECOMPOSED, pszSrc, nLen, NULL, 0 );
LPWSTR pszWide = ( LPWSTR ) hb_xgrab( ( nWideLen + 1 ) * sizeof( wchar_t ) );
char * pszDst;
MultiByteToWideChar( CP_ACP, MB_PRECOMPOSED, pszSrc, nLen, pszWide, nWideLen );
nLen = WideCharToMultiByte( CP_OEMCP, 0, pszWide, nWideLen, NULL, 0, NULL, NULL );
pszDst = ( char * ) hb_xgrab( nLen + 1 );
WideCharToMultiByte( CP_OEMCP, 0, pszWide, nWideLen, pszDst, nLen, NULL, NULL );
hb_xfree( pszWide );
hb_retclen_buffer( pszDst, nLen );
}
#else
hb_itemReturn( pString );
#endif
else
hb_retc_null();
}
HB_FUNC( CONVTOANSICP )
{
HB_FUNC_EXEC( HB_OEMTOANSI );
PHB_ITEM pString = hb_param( 1, HB_IT_STRING );
if( pString )
#if defined( HB_OS_WIN )
{
int nLen = ( int ) hb_itemGetCLen( pString );
const char * pszSrc = hb_itemGetCPtr( pString );
int nWideLen = MultiByteToWideChar( CP_OEMCP, MB_PRECOMPOSED, pszSrc, nLen, NULL, 0 );
LPWSTR pszWide = ( LPWSTR ) hb_xgrab( ( nWideLen + 1 ) * sizeof( wchar_t ) );
char * pszDst;
MultiByteToWideChar( CP_OEMCP, MB_PRECOMPOSED, pszSrc, nLen, pszWide, nWideLen );
nLen = WideCharToMultiByte( CP_ACP, 0, pszWide, nWideLen, NULL, 0, NULL, NULL );
pszDst = ( char * ) hb_xgrab( nLen + 1 );
WideCharToMultiByte( CP_ACP, 0, pszWide, nWideLen, pszDst, nLen, NULL, NULL );
hb_xfree( pszWide );
hb_retclen_buffer( pszDst, nLen );
}
#else
hb_itemReturn( pString );
#endif
else
hb_retc_null();
}

View File

@@ -56,6 +56,8 @@
#include "hbapi.h"
#include "hbapiitm.h"
#ifdef HB_LEGACY_LEVEL4
#if defined( HB_OS_WIN )
#include <windows.h>
#endif
@@ -123,3 +125,5 @@ HB_FUNC( HB_OEMTOANSI )
else
hb_retc_null();
}
#endif