示例#1
0
// ---------------------------------------------------------------------------
//  XML256TableTranscoder390: Implementation of the transcoder API
// ---------------------------------------------------------------------------
unsigned int
XML256TableTranscoder390::transcodeFrom(const  XMLByte* const       srcData
                                        , const unsigned int         srcCount
                                        ,       XMLCh* const         toFill
                                        , const unsigned int         maxChars
                                        ,       unsigned int&        bytesEaten
                                        ,       unsigned char* const charSizes)
{
    // If debugging, make sure that the block size is legal
#if defined(XERCES_DEBUG)
    checkBlockSize(maxChars);
#endif
    //
    //  Calculate the max chars we can do here. Its the lesser of the
    //  max output chars and the number of chars in the source.
    //
    const unsigned int countToDo = srcCount < maxChars ? srcCount : maxChars;

    //
    //  Loop through the count we have to do and map each char via the
    //  lookup table.
    //
    const XMLByte*  srcPtr = srcData;
    const XMLByte*  endPtr = (srcPtr + countToDo);
    XMLCh*          outPtr = toFill;
    XMLCh stop = 0xffff;

    TROT(srcData, toFill, countToDo, fFromTable, stop);

    // Set the bytes eaten
    bytesEaten = countToDo;

    // Set the character sizes to the fixed size
    memset(charSizes, 1, countToDo);

    // Return the chars we transcoded
    return countToDo;
}
示例#2
0
// ---------------------------------------------------------------------------
//  XML88591Transcoder390: Implementation of the transcoder API
// ---------------------------------------------------------------------------
unsigned int
XML88591Transcoder390::transcodeFrom(  const   XMLByte* const       srcData
                                    , const unsigned int         srcCount
                                    ,       XMLCh* const         toFill
                                    , const unsigned int         maxChars
                                    ,       unsigned int&        bytesEaten
                                    ,       unsigned char* const charSizes)
{
    // If debugging, make sure that the block size is legal
    #if defined(XERCES_DEBUG)
    checkBlockSize(maxChars);
    #endif

    //
    //  Calculate the max chars we can do here. Its the lesser of the
    //  max output chars and the number of bytes in the source.
    //
    const unsigned int countToDo = srcCount < maxChars ? srcCount : maxChars;

    //
    //  Loop through the bytes to do and convert over each byte. Its just
    //  a cast to the wide char type.
    //
    const XMLByte*  srcPtr = srcData;
    XMLCh*          destPtr = toFill;
    const XMLByte*  srcEnd = srcPtr + countToDo;

    TROT(srcPtr, destPtr, countToDo, padding_temp.gFromTable, 0xFFFF);

    // Set the bytes eaten, and set the char size array to the fixed size
    bytesEaten = countToDo;
    memset(charSizes, 1, countToDo);

    // Return the chars we transcoded
    return countToDo;
}