static BOOL hb_gt_std_SetDispCP( PHB_GT pGT, const char *pszTermCDP, const char *pszHostCDP, BOOL fBox ) { HB_TRACE( HB_TR_DEBUG, ( "hb_gt_std_SetDispCP(%p,%s,%s,%d)", pGT, pszTermCDP, pszHostCDP, (int) fBox ) ); HB_GTSUPER_SETDISPCP( pGT, pszTermCDP, pszHostCDP, fBox ); #ifndef HB_CDP_SUPPORT_OFF if( !pszHostCDP ) pszHostCDP = hb_cdpID(); if( !pszTermCDP ) pszTermCDP = pszHostCDP; if( pszTermCDP && pszHostCDP ) { PHB_GTSTD pGTSTD = HB_GTSTD_GET( pGT ); pGTSTD->cdpTerm = hb_cdpFind( pszTermCDP ); pGTSTD->cdpHost = hb_cdpFind( pszHostCDP ); pGTSTD->fDispTrans = pGTSTD->cdpTerm && pGTSTD->cdpHost && pGTSTD->cdpTerm != pGTSTD->cdpHost; return TRUE; } #endif return FALSE; }
static PHB_I18N_TRANS hb_i18n_initialize( PHB_ITEM pTable ) { PHB_I18N_TRANS pI18N = NULL; if( HB_IS_HASH( pTable ) ) { PHB_ITEM pKey, pContext, pDefContext = NULL, pValue; pKey = hb_itemPutCConst( NULL, "CONTEXT" ); pContext = hb_hashGetItemPtr( pTable, pKey, 0 ); if( pContext ) { pKey = hb_itemPutC( pKey, NULL ); pDefContext = hb_hashGetItemPtr( pContext, pKey, 0 ); } if( pContext && pDefContext ) { pI18N = ( PHB_I18N_TRANS ) hb_xgrabz( sizeof( HB_I18N_TRANS ) ); hb_atomic_set( &pI18N->iUsers, 1 ); pI18N->table = pTable; pI18N->context_table = hb_itemNew( pContext ); pI18N->default_context = hb_itemNew( pDefContext ); pKey = hb_itemPutCConst( pKey, "BASE_CODEPAGE" ); pValue = hb_hashGetItemPtr( pTable, pKey, 0 ); if( pValue ) pI18N->base_cdpage = hb_cdpFind( hb_itemGetCPtr( pValue ) ); pKey = hb_itemPutCConst( pKey, "CODEPAGE" ); pValue = hb_hashGetItemPtr( pTable, pKey, 0 ); if( pValue ) pI18N->cdpage = hb_cdpFind( hb_itemGetCPtr( pValue ) ); pKey = hb_itemPutCConst( pKey, "BASE_LANG" ); pValue = hb_hashGetItemPtr( pTable, pKey, 0 ); if( pValue ) pI18N->base_plural_form = hb_i18n_pluralformfind( hb_itemGetCPtr( pValue ) ); pKey = hb_itemPutCConst( pKey, "LANG" ); pValue = hb_hashGetItemPtr( pTable, pKey, 0 ); if( pValue ) pI18N->plural_form = hb_i18n_pluralformfind( hb_itemGetCPtr( pValue ) ); pKey = hb_itemPutCConst( pKey, "BASE_PLURAL_EXP" ); pValue = hb_hashGetItemPtr( pTable, pKey, 0 ); if( pValue ) pI18N->base_plural_block = hb_i18n_pluralexp_compile( pValue ); pKey = hb_itemPutCConst( pKey, "PLURAL_EXP" ); pValue = hb_hashGetItemPtr( pTable, pKey, 0 ); if( pValue ) pI18N->plural_block = hb_i18n_pluralexp_compile( pValue ); } hb_itemRelease( pKey ); } return pI18N; }
static BOOL hb_gt_std_SetKeyCP( PHB_GT pGT, const char *pszTermCDP, const char *pszHostCDP ) { HB_TRACE( HB_TR_DEBUG, ( "hb_gt_std_SetKeyCP(%p,%s,%s)", pGT, pszTermCDP, pszHostCDP ) ); HB_GTSUPER_SETKEYCP( pGT, pszTermCDP, pszHostCDP ); #ifndef HB_CDP_SUPPORT_OFF if( !pszHostCDP ) pszHostCDP = hb_cdpID(); if( !pszTermCDP ) pszTermCDP = pszHostCDP; if( pszTermCDP && pszHostCDP ) { PHB_CODEPAGE cdpTerm = hb_cdpFind( pszTermCDP ), cdpHost = hb_cdpFind( pszHostCDP ); if( cdpTerm && cdpHost && cdpTerm != cdpHost && cdpTerm->nChars && cdpTerm->nChars == cdpHost->nChars ) { char *pszHostLetters = ( char * ) hb_xgrab( cdpHost->nChars * 2 + 1 ); char *pszTermLetters = ( char * ) hb_xgrab( cdpTerm->nChars * 2 + 1 ); hb_strncpy( pszHostLetters, cdpHost->CharsUpper, cdpHost->nChars * 2 ); hb_strncat( pszHostLetters, cdpHost->CharsLower, cdpHost->nChars * 2 ); hb_strncpy( pszTermLetters, cdpTerm->CharsUpper, cdpTerm->nChars * 2 ); hb_strncat( pszTermLetters, cdpTerm->CharsLower, cdpTerm->nChars * 2 ); hb_gt_std_setKeyTrans( HB_GTSTD_GET( pGT ), pszTermLetters, pszHostLetters ); hb_xfree( pszHostLetters ); hb_xfree( pszTermLetters ); } else hb_gt_std_setKeyTrans( HB_GTSTD_GET( pGT ), NULL, NULL ); return TRUE; } #endif return FALSE; }
static HB_ERRCODE adsxOpen( ADSXAREAP pArea, LPDBOPENINFO pOpenInfo ) { if( SUPER_OPEN( ( AREAP ) pArea, pOpenInfo ) == HB_SUCCESS ) { if( pOpenInfo->cdpId ) { pArea->adsarea.area.cdPage = hb_cdpFind( pOpenInfo->cdpId ); if( ! pArea->adsarea.area.cdPage ) pArea->adsarea.area.cdPage = hb_vmCDP(); } else pArea->adsarea.area.cdPage = hb_vmCDP(); return HB_SUCCESS; } return HB_FAILURE; }
static const char * hb_i18n_setcodepage( PHB_I18N_TRANS pI18N, const char * szCdpID, HB_BOOL fBase, HB_BOOL fTranslate ) { const char * szOldCdpID = NULL, * szKey; if( pI18N ) { PHB_CODEPAGE cdp = szCdpID ? hb_cdpFind( szCdpID ) : NULL, cdpage; cdpage = fBase ? pI18N->base_cdpage : pI18N->cdpage; if( cdpage ) szOldCdpID = cdpage->id; if( cdp && cdp != cdpage ) { if( fTranslate && cdpage ) { HB_SIZE nHashLen = hb_hashLen( pI18N->context_table ), ul; for( ul = 1; ul <= nHashLen; ++ul ) { PHB_ITEM pContext = hb_hashGetValueAt( pI18N->context_table, ul ); HB_SIZE nCount = hb_hashLen( pContext ), u; for( u = 1; u <= nCount; ++u ) { if( fBase ) { hb_i18n_transitm( hb_hashGetKeyAt( pContext, u ), cdpage, cdp ); } else { PHB_ITEM pResult = hb_hashGetValueAt( pContext, u ); if( HB_IS_STRING( pResult ) ) { hb_i18n_transitm( pResult, cdpage, cdp ); } else if( HB_IS_ARRAY( pResult ) ) { HB_SIZE nTrans = hb_arrayLen( pResult ), u2; for( u2 = 1; u2 <= nTrans; ++u2 ) { hb_i18n_transitm( hb_arrayGetItemPtr( pResult, u2 ), cdpage, cdp ); } } } } if( fBase ) { hb_i18n_transitm( hb_hashGetKeyAt( pI18N->context_table, ul ), cdpage, cdp ); hb_hashSetFlags( pContext, HB_HASH_RESORT ); } } if( fBase ) hb_hashSetFlags( pI18N->context_table, HB_HASH_RESORT ); } if( fBase ) { pI18N->base_cdpage = cdp; szKey = "BASE_CODEPAGE"; } else { pI18N->cdpage = cdp; szKey = "CODEPAGE"; } hb_i18n_setitem( pI18N->table, szKey, szCdpID ); } } return szOldCdpID; }