Logo Search packages:      
Sourcecode: libpodofo version File versions  Download package

PdfString PoDoFo::PdfDifferenceEncoding::ConvertToUnicode ( const PdfString rEncodedString,
const PdfFont pFont 
) const [virtual]

Convert a string that is encoded with this encoding to an unicode PdfString.

rEncodedStringa string encoded by this encoding. Usually this string was read from a content stream.
pFontthe font for which this string is converted
an unicode PdfString.

Implements PoDoFo::PdfEncoding.

Definition at line 2513 of file PdfDifferenceEncoding.cpp.

References PoDoFo::PdfEncodingDifference::Contains(), PoDoFo::PdfEncoding::ConvertToUnicode(), PoDoFo::ePdfError_OutOfMemory, GetBaseEncoding(), PoDoFo::PdfString::GetCharacterLength(), PoDoFo::PdfString::GetUnicode(), and PODOFO_RAISE_ERROR.

    const PdfEncoding* pEncoding = GetBaseEncoding();
    PdfString str  = pEncoding->ConvertToUnicode( rEncodedString, pFont );
    pdf_long      lLen = str.GetCharacterLength();

    pdf_utf16be* pszUtf16 = static_cast<pdf_utf16be*>(malloc(sizeof(pdf_utf16be)*lLen));
    if( !pszUtf16 )
        PODOFO_RAISE_ERROR( ePdfError_OutOfMemory );

    memcpy( pszUtf16, str.GetUnicode(), lLen * sizeof(pdf_utf16be) );

    for( pdf_long i=0;i<lLen;i++ ) 
        pdf_utf16be val = pszUtf16[i];
        val = ((val & 0xff00) >> 8) | ((val & 0xff) << 8);

        PdfName     name;
        pdf_utf16be value;
        if( m_differences.Contains( static_cast<int>(val), name, value ) )
            pszUtf16[i] = value;

    PdfString ret( pszUtf16, lLen );
    free( pszUtf16 );

    return ret;

Here is the call graph for this function:

Generated by  Doxygen 1.6.0   Back to index