Ignore:
Timestamp:
Mar 31, 2010, 9:50:47 PM (12 years ago)
Author:
dmik
Message:

branches/kmk: Added a bunch of unicode conversion helpers based on the original propcnv() from lupoppler.cpp.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/kmk/Lucide/plugins/lupoppler/lupoppler.cpp

    r330 r337  
    972972static char *newstrFromUTF8( const char *s, void *objUtf8, void *objSys )
    973973{
    974     size_t cSubs = 0;
    975     size_t len = strlen( s ) + 1;
    976     size_t unilen = len + 2;
    977     UniChar *unibuf = new UniChar[ unilen ];
    978     UniChar *tmpuni = unibuf;
    979     UniUconvToUcs( objUtf8, (void **)&s, &len, &tmpuni, &unilen, &cSubs );
    980     unilen = UniStrlen( unibuf );
    981 
    982     int liglen = uniLigaturesLength( unibuf );
    983     if ( liglen > 0 )  // string contain ligature(s)
    984     {
    985         unsigned ulen_tmp = ( unilen + liglen + 1 ) * sizeof( UniChar );
    986         char *uni_tmp = new char[ ulen_tmp ];
    987         uniReplaceLigatures( unibuf, (UniChar *)uni_tmp );
    988         delete unibuf;
    989         unibuf = (UniChar *)uni_tmp;
    990         unilen = UniStrlen( unibuf );
    991     }
    992     uniConvertSpChars( unibuf );
    993 
    994     size_t blen = ( unilen + 1 ) * 2;
    995     char *b = new char[ blen ];
    996     memset( b, 0, blen );
    997     char *bsav = b;
    998     tmpuni = unibuf;
    999     cSubs = 0;
    1000     UniUconvFromUcs( objSys, &tmpuni, &unilen, (void **)&b, &blen, &cSubs );
    1001     delete unibuf;
    1002     return bsav;
     974    return uniConvertString( s, strlen( s ), &objUtf8, &objSys, NULL );
    1003975}
    1004976
     
    10691041    if ( has_unicode_marker( s ) )
    10701042    {
    1071         size_t cSubs = 0;
    1072         size_t unilen = s->getLength() + 1;
    1073         UniChar *unibuf = new UniChar[ unilen ];
    1074         memset( unibuf, 0, unilen * sizeof( UniChar ) );
    1075         UniChar *tmpuni = unibuf;
    1076         const char *from = s->getCString() + 2;
    1077         size_t fromlen = s->getLength() - 2;
    1078         UniUconvToUcs( objUniBe, (void **)&from, &fromlen, &tmpuni, &unilen, &cSubs );
    1079         unilen = UniStrlen( unibuf );
    1080 
    1081         int liglen = uniLigaturesLength( unibuf );
    1082         if ( liglen > 0 )  // string contain ligature(s)
    1083         {
    1084             unsigned ulen_tmp = ( unilen + liglen + 1 ) * sizeof( UniChar );
    1085             char *uni_tmp = new char[ ulen_tmp ];
    1086             uniReplaceLigatures( unibuf, (UniChar *)uni_tmp );
    1087             delete unibuf;
    1088             unibuf = (UniChar *)uni_tmp;
    1089             unilen = UniStrlen( unibuf );
    1090         }
    1091         uniConvertSpChars( unibuf );
    1092 
    1093         size_t blen = ( unilen + 1 ) * 2;
    1094         char *b = (char *)SOMMalloc( blen );
    1095         memset( b, 0, blen );
    1096         char *bsav = b;
    1097         tmpuni = unibuf;
    1098         cSubs = 0;
    1099         UniUconvFromUcs( objSys, &tmpuni, &unilen, (void **)&b, &blen, &cSubs );
    1100         delete unibuf;
    1101         return bsav;
     1043        char *str = uniUtf16BEToSys( s->getCString(), s->getLength(), &objUniBe,
     1044                                     &objSys );
     1045        char *ret = somstrdup( str );
     1046        delete[] str;
     1047        return ret;
    11021048    }
    11031049
Note: See TracChangeset for help on using the changeset viewer.