Skip to content
Snippets Groups Projects
Win32TransService.cpp 31.2 KiB
Newer Older
PeiYong Zhang's avatar
PeiYong Zhang committed
    {
        toFill[0] = 0;
        return true;
    }

    // This one has a fixed size output, so try it and if it fails it fails
    if ( 0 == ::MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, toTranscode, -1, (LPWSTR)toFill, maxChars + 1) )
PeiYong Zhang's avatar
PeiYong Zhang committed
        return false;
    return true;
}


bool Win32LCPTranscoder::transcode( const   XMLCh* const    toTranscode
                                    ,       char* const     toFill
                                    , const unsigned int    maxBytes
                                    , MemoryManager* const  manager)
PeiYong Zhang's avatar
PeiYong Zhang committed
{
    // Watch for a couple of pyscho corner cases
    if (!toTranscode || !maxBytes)
    {
        toFill[0] = 0;
        return true;
    }

    if (!*toTranscode)
    {
        toFill[0] = 0;
        return true;
    }

    // This one has a fixed size output, so try it and if it fails it fails
    if ( 0 == ::WideCharToMultiByte(CP_ACP, 0, (LPCWSTR)toTranscode, -1, toFill, maxBytes + 1, NULL, NULL) )
PeiYong Zhang's avatar
PeiYong Zhang committed
        return false;

    // Cap it off just in case
    toFill[maxBytes] = 0;
    return true;
}


Tinny Ng's avatar
Tinny Ng committed
XERCES_CPP_NAMESPACE_END