From 021ceb93061af71570bec340bf344e87e7327864 Mon Sep 17 00:00:00 2001 From: Mindaugas Kavaliauskas Date: Sat, 13 Nov 2010 02:50:05 +0000 Subject: [PATCH] 2010-11-13 04:48 UTC+0300 Mindaugas Kavaliauskas (dbtopas/at/dbtopas.lt) * harbour/contrib/hbzebra/datamtrx.c + added support for full 0..255 range character encoding. We are still using ASCII encode mode only. --- harbour/ChangeLog | 5 +++++ harbour/contrib/hbzebra/datamtrx.c | 28 +++++++++++++++------------- 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index fee41a2186..867865ec8e 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -16,6 +16,11 @@ The license applies to all entries newer than 2009-04-28. */ +2010-11-13 04:48 UTC+0300 Mindaugas Kavaliauskas (dbtopas/at/dbtopas.lt) + * harbour/contrib/hbzebra/datamtrx.c + + added support for full 0..255 range character encoding. We are still + using ASCII encode mode only. + 2010-11-13 04:28 UTC+0300 Mindaugas Kavaliauskas (dbtopas/at/dbtopas.lt) * harbour/contrib/hbzebra/datamtrx.c ! fixed typo diff --git a/harbour/contrib/hbzebra/datamtrx.c b/harbour/contrib/hbzebra/datamtrx.c index 8ac8210cfd..e95cd13fa4 100644 --- a/harbour/contrib/hbzebra/datamtrx.c +++ b/harbour/contrib/hbzebra/datamtrx.c @@ -140,14 +140,19 @@ static int _datamatrix_encode( const char * szCode, int iLen, char * pCW ) pCW[ iPos++ ] = ( szCode[ i ] - '0' ) * 10 + szCode[ i + 1 ] - '0' + 130; i++; } - else + else if( ( unsigned char ) szCode[ i ] <= 127 ) + { pCW[ iPos++ ] = szCode[ i ] + 1; + } + else + { + pCW[ iPos++ ] = ( char ) 235; /* Shift to extended ASCII for 1 character */ + pCW[ iPos++ ] = szCode[ i ] - 127; + } } return iPos; } - - static void _reed_solomon_encode( unsigned char * pData, int iDataLen, unsigned char * pEC, int iECLen, int * pPoly, int * pExp, int * pLog, int iMod ) { int i, j; @@ -411,18 +416,15 @@ PHB_ZEBRA hb_zebra_create_datamatrix( const char * szCode, HB_SIZE nLen, int iFl return pZebra; } - for( i = 0; i < iLen; i++ ) - { - if( ( unsigned char ) szCode[ i ] >= 128 ) - { - pZebra->iError = HB_ZEBRA_ERROR_INVALIDCODE; - return pZebra; - } - } - - pCW = ( char * ) hb_xgrab( sizeof( char ) * iLen ); + pCW = ( char * ) hb_xgrab( sizeof( char ) * iLen * 2 ); iDataCount = _datamatrix_encode( szCode, iLen, pCW ); + if( iDataCount > 3116 ) + { + pZebra->iError = HB_ZEBRA_ERROR_TOOLARGE; + return pZebra; + } + pSize = NULL; for( i = 0; i < SIZE_COUNT; i++ ) {