You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by ar...@locus.apache.org on 2000/09/29 00:42:49 UTC

cvs commit: xml-xerces/c/src/util/Transcoders/Iconv400 Iconv400TransService.cpp Iconv400TransService.hpp

aruna1      00/09/28 15:42:49

  Modified:    c/src/util/Compilers OS400SetDefs.hpp
               c/src/util/MsgLoaders/MsgFile MsgLoader.cpp MsgLoader.hpp
               c/src/util/Platforms/OS400 OS400PlatformUtils.cpp
               c/src/util/Transcoders/Iconv400 Iconv400TransService.cpp
                        Iconv400TransService.hpp
  Log:
  AS400 related changes forwarded by Linda M Swan/Rochester/IBM@IBMUS
  
  Revision  Changes    Path
  1.4       +2 -5      xml-xerces/c/src/util/Compilers/OS400SetDefs.hpp
  
  Index: OS400SetDefs.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/util/Compilers/OS400SetDefs.hpp,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- OS400SetDefs.hpp	2000/03/02 19:55:09	1.3
  +++ OS400SetDefs.hpp	2000/09/28 22:42:44	1.4
  @@ -55,15 +55,7 @@
    */
   
   /*
  - * $Log: OS400SetDefs.hpp,v $
  - * Revision 1.3  2000/03/02 19:55:09  roddey
  - * This checkin includes many changes done while waiting for the
  - * 1.1.0 code to be finished. I can't list them all here, but a list is
  - * available elsewhere.
  - *
  - * Revision 1.2  2000/02/06 07:48:18  rahulj
  - * Year 2K copyright swat.
  - *
  + * $Id: OS400SetDefs.hpp,v 1.4 2000/09/28 22:42:44 aruna1 Exp $
    */
   
   
  @@ -112,6 +104,6 @@
   //  versioning string. This is defined in XercesDefs.hpp which is what this
   //  file is included into.
   // ---------------------------------------------------------------------------
  -const char* const Xerces_DLLName = "QXML4C";
  +const char* const Xerces_DLLName = "libxercesc";
   
   #endif
  
  
  
  1.5       +5 -13     xml-xerces/c/src/util/MsgLoaders/MsgFile/MsgLoader.cpp
  
  Index: MsgLoader.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/util/MsgLoaders/MsgFile/MsgLoader.cpp,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- MsgLoader.cpp	2000/07/25 22:28:47	1.4
  +++ MsgLoader.cpp	2000/09/28 22:42:44	1.5
  @@ -55,18 +55,7 @@
    */
   
   /*
  - * $Log: MsgLoader.cpp,v $
  - * Revision 1.4  2000/07/25 22:28:47  aruna1
  - * Char definitions in XMLUni moved to XMLUniDefs
  - *
  - * Revision 1.3  2000/03/02 19:55:17  roddey
  - * This checkin includes many changes done while waiting for the
  - * 1.1.0 code to be finished. I can't list them all here, but a list is
  - * available elsewhere.
  - *
  - * Revision 1.2  2000/02/06 07:48:23  rahulj
  - * Year 2K copyright swat.
  - *
  + * $Id: MsgLoader.cpp,v 1.5 2000/09/28 22:42:44 aruna1 Exp $
    */
   
   // ---------------------------------------------------------------------------
  @@ -156,7 +145,7 @@
   
   bool localMsg(char * msgId
                               ,       XMLCh* const            toFill
  -                            , const unsigned long           maxChars
  +                            , const unsigned int            maxChars
   			    ,		char*		    repTexts
   			    ,		int		    size)
   {
  @@ -209,7 +198,7 @@
   
   bool MsgCatalogLoader::loadMsg(const  XMLMsgLoader::XMLMsgId  msgToLoad
                               ,       XMLCh* const            toFill
  -                            , const unsigned long           maxChars)
  +                            , const unsigned int            maxChars)
   {
       char * msgId;
       char * repTexts = NULL;
  @@ -235,7 +224,7 @@
   
   bool MsgCatalogLoader::loadMsg(const  XMLMsgLoader::XMLMsgId  msgToLoad
                               ,       XMLCh* const            toFill
  -                            , const unsigned long           maxChars
  +                            , const unsigned int            maxChars
                               , const char* const            repText1
                               , const char* const            repText2
                               , const char* const            repText3
  @@ -267,7 +256,7 @@
   
   bool MsgCatalogLoader::loadMsg(const  XMLMsgLoader::XMLMsgId  msgToLoad
                               ,       XMLCh* const            toFill
  -                            , const unsigned long           maxChars
  +                            , const unsigned int           maxChars
                               , const XMLCh* const             repText1
                               , const XMLCh* const             repText2
                               , const XMLCh* const             repText3
  
  
  
  1.4       +4 -7      xml-xerces/c/src/util/MsgLoaders/MsgFile/MsgLoader.hpp
  
  Index: MsgLoader.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/util/MsgLoaders/MsgFile/MsgLoader.hpp,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- MsgLoader.hpp	2000/03/02 19:55:18	1.3
  +++ MsgLoader.hpp	2000/09/28 22:42:44	1.4
  @@ -55,15 +55,7 @@
    */
   
   /*
  - * $Log: MsgLoader.hpp,v $
  - * Revision 1.3  2000/03/02 19:55:18  roddey
  - * This checkin includes many changes done while waiting for the
  - * 1.1.0 code to be finished. I can't list them all here, but a list is
  - * available elsewhere.
  - *
  - * Revision 1.2  2000/02/06 07:48:23  rahulj
  - * Year 2K copyright swat.
  - *
  + * $Id: MsgLoader.hpp,v 1.4 2000/09/28 22:42:44 aruna1 Exp $
    */
   
   #if !defined(ICONVMSGLOADER_HPP)
  @@ -94,14 +86,14 @@
       (
           const   XMLMsgLoader::XMLMsgId  msgToLoad
           ,       XMLCh* const            toFill
  -        , const unsigned long           maxChars
  +        , const unsigned int            maxChars
       );
   
       virtual bool loadMsg
       (
           const   XMLMsgLoader::XMLMsgId  msgToLoad
           ,       XMLCh* const            toFill
  -        , const unsigned long           maxChars
  +        , const unsigned int            maxChars
           , const XMLCh* const            repText1
           , const XMLCh* const            repText2 = 0
           , const XMLCh* const            repText3 = 0
  @@ -112,7 +104,7 @@
       (
           const   XMLMsgLoader::XMLMsgId  msgToLoad
           ,       XMLCh* const            toFill
  -        , const unsigned long           maxChars
  +        , const unsigned int            maxChars
           , const char* const             repText1
           , const char* const             repText2 = 0
           , const char* const             repText3 = 0
  
  
  
  1.5       +18 -27    xml-xerces/c/src/util/Platforms/OS400/OS400PlatformUtils.cpp
  
  Index: OS400PlatformUtils.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/util/Platforms/OS400/OS400PlatformUtils.cpp,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- OS400PlatformUtils.cpp	2000/07/25 22:30:33	1.4
  +++ OS400PlatformUtils.cpp	2000/09/28 22:42:45	1.5
  @@ -55,19 +55,7 @@
    */
   
   /**
  - * $Log: OS400PlatformUtils.cpp,v $
  - * Revision 1.4  2000/07/25 22:30:33  aruna1
  - * Char definitions in XMLUni moved to XMLUniDefs
  - *
  - * Revision 1.3  2000/03/18 00:00:01  roddey
  - * Initial updates for two way transcoding support
  - *
  - * Revision 1.2  2000/03/02 21:10:38  abagchi
  - * Added empty function platformTerm()
  - *
  - * Revision 1.1  2000/02/10 17:58:07  abagchi
  - * Initial checkin
  - *
  + * $Id: OS400PlatformUtils.cpp,v 1.5 2000/09/28 22:42:45 aruna1 Exp $
    */
   
   // ---------------------------------------------------------------------------
  @@ -121,7 +109,7 @@
   {
       if (fputs(toWrite, stream) == EOF)
       {
  -	ThrowXML(XMLPlatformUtilsException, XML4CExcepts::Strm_StdErrWriteFailure);
  +	ThrowXML(XMLPlatformUtilsException, XMLExcepts::Strm_StdErrWriteFailure);
       }
   }
   
  @@ -132,7 +120,7 @@
       ArrayJanitor<char> janText(tmpVal);
       if (fputs(tmpVal, stderr) == EOF)
       {
  -		ThrowXML(XMLPlatformUtilsException, XML4CExcepts::Strm_StdErrWriteFailure);
  +		ThrowXML(XMLPlatformUtilsException, XMLExcepts::Strm_StdErrWriteFailure);
       }
   }
   
  @@ -143,7 +131,7 @@
       ArrayJanitor<char> janText(tmpVal);
       if (fputs(tmpVal, stdout) == EOF)
       {
  -		ThrowXML(XMLPlatformUtilsException, XML4CExcepts::Strm_StdOutWriteFailure);
  +		ThrowXML(XMLPlatformUtilsException, XMLExcepts::Strm_StdOutWriteFailure);
       }
   }
   XMLNetAccessor* XMLPlatformUtils::makeNetAccessor()
  @@ -254,7 +242,7 @@
       // Get the current position
       int curPos = ftell( (FILE*)theFile);
       if (curPos == -1)
  -	ThrowXML(XMLPlatformUtilsException, XML4CExcepts::File_CouldNotGetSize);
  +	ThrowXML(XMLPlatformUtilsException, XMLExcepts::File_CouldNotGetSize);
   
       return (unsigned int)curPos;
   }
  @@ -262,7 +250,7 @@
   void XMLPlatformUtils::closeFile(FileHandle theFile)
   {
       if (fclose((FILE*)theFile))
  -	ThrowXML(XMLPlatformUtilsException, XML4CExcepts::File_CouldNotCloseFile);
  +	ThrowXML(XMLPlatformUtilsException, XMLExcepts::File_CouldNotCloseFile);
   }
   
   
  @@ -271,19 +259,19 @@
       // Get the current position
       long  int curPos = ftell((FILE*)theFile);
       if (curPos == -1)
  -		ThrowXML(XMLPlatformUtilsException, XML4CExcepts::File_CouldNotGetCurPos);
  +		ThrowXML(XMLPlatformUtilsException, XMLExcepts::File_CouldNotGetCurPos);
   
       // Seek to the end and save that value for return
        if (fseek( (FILE*)theFile, 0, SEEK_END) )
  -		ThrowXML(XMLPlatformUtilsException, XML4CExcepts::File_CouldNotSeekToEnd);
  +		ThrowXML(XMLPlatformUtilsException, XMLExcepts::File_CouldNotSeekToEnd);
   
       long int retVal = ftell( (FILE*)theFile);
       if (retVal == -1)
  -		ThrowXML(XMLPlatformUtilsException, XML4CExcepts::File_CouldNotSeekToEnd);
  +		ThrowXML(XMLPlatformUtilsException, XMLExcepts::File_CouldNotSeekToEnd);
   
       // And put the pointer back
       if (fseek( (FILE*)theFile, curPos, SEEK_SET) )
  -		ThrowXML(XMLPlatformUtilsException, XML4CExcepts::File_CouldNotSeekToPos);
  +		ThrowXML(XMLPlatformUtilsException, XMLExcepts::File_CouldNotSeekToPos);
   
       return (unsigned int)retVal;
   }
  @@ -332,7 +320,7 @@
   
       if(ferror((FILE*)theFile))
       {
  -		ThrowXML(XMLPlatformUtilsException, XML4CExcepts::File_CouldNotReadFromFile);
  +		ThrowXML(XMLPlatformUtilsException, XMLExcepts::File_CouldNotReadFromFile);
       }
       return (unsigned int)noOfItemsRead;
   }
  @@ -342,7 +330,7 @@
   {
       // Seek to the start of the file
       if (fseek((FILE*)theFile, 0, SEEK_SET) )
  -		ThrowXML(XMLPlatformUtilsException, XML4CExcepts::File_CouldNotResetFile);
  +		ThrowXML(XMLPlatformUtilsException, XMLExcepts::File_CouldNotResetFile);
   }
   
   
  @@ -408,7 +396,7 @@
   	
       if (!retPath)
       {
  -		ThrowXML(XMLPlatformUtilsException, XML4CExcepts::File_CouldNotGetBasePathName);
  +		ThrowXML(XMLPlatformUtilsException, XMLExcepts::File_CouldNotGetBasePathName);
       }
       return XMLString::transcode(absPath);
   
  @@ -526,7 +514,7 @@
   
               // The base cannot provide enough levels, so its in error/
               if (basePtr < basePath)
  -                ThrowXML(PlatformUtilsException, File_BasePathUnderflow);
  +                ThrowXML(XMLPlatformUtilsException, XMLExcepts::File_BasePathUnderflow);
           }
       }
   
  @@ -644,7 +632,7 @@
   
       RecursiveMutex() { 
   		       if (pthread_mutex_init(&mutex, NULL))
  -			    ThrowXML(XMLPlatformUtilsException, XML4CExcepts::Mutex_CouldNotCreate);
  +			    ThrowXML(XMLPlatformUtilsException, XMLExcepts::Mutex_CouldNotCreate);
                          recursionCount = 0;
                          tid.reservedHiId = 0;
   		       tid.reservedLoId = 0;
  @@ -653,7 +641,7 @@
   
       ~RecursiveMutex() {
   			if (pthread_mutex_destroy(&mutex))
  -			    ThrowXML(XMLPlatformUtilsException, XML4CExcepts::Mutex_CouldNotDestroy);
  +			    ThrowXML(XMLPlatformUtilsException, XMLExcepts::Mutex_CouldNotDestroy);
                         };
   
        void lock()      {
  @@ -663,7 +651,7 @@
   			      return;
   			  }
   			  if (pthread_mutex_lock(&mutex) != 0)
  -			      ThrowXML(XMLPlatformUtilsException, XML4CExcepts::Mutex_CouldNotLock);
  +			      ThrowXML(XMLPlatformUtilsException, XMLExcepts::Mutex_CouldNotLock);
   			  tid = pthread_self();
   			  recursionCount = 1;
   		      };
  @@ -674,7 +662,7 @@
                                 return;
   
   			  if (pthread_mutex_unlock(&mutex) != 0)
  -			      ThrowXML(XMLPlatformUtilsException, XML4CExcepts::Mutex_CouldNotUnlock);
  +			      ThrowXML(XMLPlatformUtilsException, XMLExcepts::Mutex_CouldNotUnlock);
                             tid.reservedHandle= 0;
   			  tid.reservedHiId = 0;
   			  tid.reservedLoId = 0;
  
  
  
  1.4       +275 -8    xml-xerces/c/src/util/Transcoders/Iconv400/Iconv400TransService.cpp
  
  Index: Iconv400TransService.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/util/Transcoders/Iconv400/Iconv400TransService.cpp,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Iconv400TransService.cpp	2000/09/12 17:06:48	1.3
  +++ Iconv400TransService.cpp	2000/09/28 22:42:45	1.4
  @@ -55,16 +55,7 @@
    */
   
   /**
  - * $Log: Iconv400TransService.cpp,v $
  - * Revision 1.3  2000/09/12 17:06:48  aruna1
  - * Replaced INDEX_OUTOFBOUNDS error to BUFFER_OVERFLOW error for toUnicode and from_Unicode functions for compatibility with icu 1.6
  - *
  - * Revision 1.2  2000/02/11 03:06:58  rahulj
  - * Cosmetic changes. Replaced tabs with appropriate number of spaces.
  - *
  - * Revision 1.1  2000/02/10 18:08:28  abagchi
  - * Initial checkin
  - *
  + * $Id: Iconv400TransService.cpp,v 1.4 2000/09/28 22:42:45 aruna1 Exp $
    */
   
   // ---------------------------------------------------------------------------
  @@ -77,8 +68,34 @@
   #include "iconv_cnv.h"
   #include "iconv_util.h"
   #include <qusec.h>
  +#include <util/XMLUniDefs.hpp>
  +#include <util/XMLString.hpp>
  +#include <util/Janitor.hpp>
   
  +// ---------------------------------------------------------------------------
  +//  Local functions
  +// ---------------------------------------------------------------------------
  +
  +//
  +//  When XMLCh and ICU's UChar are not the same size, we have to do a temp
  +//  conversion of all strings. These local helper methods make that easier.
  +//
  +static UChar* convertToUChar(   const   XMLCh* const    toConvert
  +                                , const unsigned int    srcLen = 0)
  +{
  +    const unsigned int actualLen = srcLen
  +                                   ? srcLen : XMLString::stringLen(toConvert);
  +
  +    UChar* tmpBuf = new UChar[srcLen + 1];
  +    const XMLCh* srcPtr = toConvert;
  +    UChar* outPtr = tmpBuf;
  +    while (*srcPtr)
  +        *outPtr++ = UChar(*srcPtr++);
  +    *outPtr = 0;
   
  +    return tmpBuf;
  +}
  +
   int32_t u_strlen(const XMLCh *s)
   {
       int32_t i=0;
  @@ -379,7 +396,7 @@
       );
   
       if ((err != U_ZERO_ERROR) && (err != U_BUFFER_OVERFLOW_ERROR))
  -        ThrowXML(TranscodingException, XML4CExcepts::Trans_CouldNotXCodeXMLData);
  +        ThrowXML(TranscodingException, XMLExcepts::Trans_Unrepresentable);
   
       // Calculate the bytes eaten and store in caller's param
       bytesEaten = startSrc - srcData;
  @@ -426,6 +443,253 @@
       return charsDecoded;
   }
   
  +// ---------------------------------------------------------------------------
  +//  Iconv400Transcoder: The virtual transcoder API
  +// ---------------------------------------------------------------------------
  +unsigned int
  +Iconv400Transcoder::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, insure the block size is legal
  +
  +
  +    // Set up pointers to the start and end of the source buffer
  +    const XMLByte*  startSrc = srcData;
  +    const XMLByte*  endSrc = srcData + srcCount;
  +
  +    //
  +    //  And now do the target buffer. This works differently according to
  +    //  whether XMLCh and UChar are the same size or not.
  +    //
  +    UChar* startTarget;
  +    if (sizeof(XMLCh) == sizeof(UChar))
  +        startTarget = (UChar*)toFill;
  +     else
  +        startTarget = new UChar[maxChars];
  +    UChar* orgTarget = startTarget;
  +
  +    //
  +    //  Transoode the buffer.  Buffer overflow errors are normal, occuring
  +    //  when the raw input buffer holds more characters than will fit in
  +    //  the Unicode output buffer.
  +    //
  +    UErrorCode  err = U_ZERO_ERROR;
  +    ucnv_toUnicode
  +    (
  +        fConverter
  +        , &startTarget
  +        , startTarget + maxChars
  +        , (const char**)&startSrc
  +        , (const char*)endSrc
  +        , (fFixed ? 0 : (int32_t*)fSrcOffsets)
  +        , false
  +        , &err
  +    );
  +
  +    if ((err != U_ZERO_ERROR) && (err != U_INDEX_OUTOFBOUNDS_ERROR))
  +    {
  +        if (orgTarget != (UChar*)toFill)
  +            delete [] orgTarget;
  +
  +        if (fFixed)
  +        {
  +            XMLCh tmpBuf[16];
  +            XMLString::binToText((unsigned int)(*startTarget), tmpBuf, 16, 16);
  +            ThrowXML2
  +            (
  +                TranscodingException
  +                , XMLExcepts::Trans_BadSrcCP
  +                , tmpBuf
  +                , getEncodingName()
  +            );
  +        }
  +         else
  +        {
  +            ThrowXML(TranscodingException, XMLExcepts::Trans_BadSrcSeq);
  +        }
  +    }
  +
  +    // Calculate the bytes eaten and store in caller's param
  +    bytesEaten = startSrc - srcData;
  +
  +    // And the characters decoded
  +    const unsigned int charsDecoded = startTarget - orgTarget;
  +
  +    //
  +    //  Translate the array of char offsets into an array of character
  +    //  sizes, which is what the transcoder interface semantics requires.
  +    //  If its fixed, then we can optimize it.
  +    //
  +    if (fFixed)
  +    {
  +        const unsigned char fillSize = (unsigned char)ucnv_getMaxCharSize(fConverter);;
  +        memset(charSizes, fillSize, maxChars);
  +    }
  +     else
  +    {
  +        //
  +        //  We have to convert the series of offsets into a series of
  +        //  sizes. If just one char was decoded, then its the total bytes
  +        //  eaten. Otherwise, do a loop and subtract out each element from
  +        //  its previous element.
  +        //
  +        if (charsDecoded == 1)
  +        {
  +            charSizes[0] = (unsigned char)bytesEaten;
  +        }
  +         else
  +        {
  +            // <TBD> Does ICU return an extra element to allow us to figure
  +            //  out the last char size? It better!!
  +            unsigned int index;
  +            for (index = 0; index < charsDecoded; index++)
  +            {
  +                charSizes[index] = (unsigned char)(fSrcOffsets[index + 1]
  +                                                    - fSrcOffsets[index]);
  +            }
  +        }
  +    }
  +
  +    //
  +    //  If XMLCh and UChar are not the same size, then we need to copy over
  +    //  the temp buffer to the new one.
  +    //
  +    if (sizeof(UChar) != sizeof(XMLCh))
  +    {
  +        XMLCh* outPtr = toFill;
  +        startTarget = orgTarget;
  +        for (unsigned int index = 0; index < charsDecoded; index++)
  +            *outPtr++ = XMLCh(*startTarget++);
  +
  +        // And delete the temp buffer
  +        delete [] orgTarget;
  +    }
  +
  +    // Return the chars we put into the target buffer
  +    return charsDecoded;
  +}
  +
  +
  +unsigned int
  +Iconv400Transcoder::transcodeTo( const   XMLCh* const    srcData
  +                            , const unsigned int    srcCount
  +                            ,       XMLByte* const  toFill
  +                            , const unsigned int    maxBytes
  +                            ,       unsigned int&   charsEaten
  +                            , const UnRepOpts       options)
  +{
  +    //
  +    //  Get a pointer to the buffer to transcode. If UChar and XMLCh are
  +    //  the same size here, then use the original. Else, create a temp
  +    //  one and put a janitor on it.
  +    //
  +    const UChar* srcPtr;
  +    UChar* tmpBufPtr = 0;
  +    if (sizeof(XMLCh) == sizeof(UChar))
  +    {
  +        srcPtr = (const UChar*)srcData;
  +    }
  +     else
  +    {
  +        tmpBufPtr = convertToUChar(srcData, srcCount);
  +        srcPtr = tmpBufPtr;
  +    }
  +    ArrayJanitor<UChar> janTmpBuf(tmpBufPtr);
  +
  +    //
  +    //  Set the appropriate callback so that it will either fail or use
  +    //  the rep char. Remember the old one so we can put it back.
  +    //
  +    UErrorCode  err = U_ZERO_ERROR;
  +
  +
  +    //
  +    //  Ok, lets transcode as many chars as we we can in one shot. The
  +    //  ICU API gives enough info not to have to do this one char by char.
  +    //
  +    XMLByte*        startTarget = toFill;
  +    const UChar*    startSrc = srcPtr;
  +    err = U_ZERO_ERROR;
  +    ucnv_fromUnicode
  +    (
  +        fConverter
  +        , (char**)&startTarget
  +        , (char*)(startTarget + maxBytes)
  +        , &startSrc
  +        , srcPtr + srcCount
  +        , 0
  +        , false
  +        , &err
  +    );
  +
  +
  +    if (!err)
  +    {
  +        XMLCh tmpBuf[16];
  +        XMLString::binToText((unsigned int)*startSrc, tmpBuf, 16, 16);
  +        ThrowXML2
  +        (
  +            TranscodingException
  +            , XMLExcepts::Trans_Unrepresentable
  +            , tmpBuf
  +            , getEncodingName()
  +        );
  +    }
  +
  +    // Fill in the chars we ate from the input
  +    charsEaten = startSrc - srcPtr;
  +
  +    // Return the chars we stored
  +    return startTarget - toFill;
  +}
  +
  +
  +bool Iconv400Transcoder::canTranscodeTo(const unsigned int toCheck) const
  +{
  +    //
  +    //  If the passed value is really a surrogate embedded together, then
  +    //  we need to break it out into its two chars. Else just one. While
  +    //  we are ate it, convert them to UChar format if required.
  +    //
  +    UChar           srcBuf[2];
  +    unsigned int    srcCount = 1;
  +    if (toCheck & 0xFFFF0000)
  +    {
  +        srcBuf[0] = UChar((toCheck >> 10) + 0xD800);
  +        srcBuf[1] = UChar(toCheck & 0x3FF) + 0xDC00;
  +        srcCount++;
  +    }
  +     else
  +    {
  +        srcBuf[0] = UChar(toCheck);
  +    }
  +
  +
  +    // Set upa temp buffer to format into. Make it more than big enough
  +    char            tmpBuf[64];
  +    char*           startTarget = tmpBuf;
  +    const UChar*    startSrc = srcBuf;
  +    UErrorCode  err = U_ZERO_ERROR;
  +   
  +    ucnv_fromUnicode
  +    (
  +        fConverter
  +        , &startTarget
  +        , startTarget + 64
  +        , &startSrc
  +        , srcBuf + srcCount
  +        , 0
  +        , false
  +        , &err
  +    );
  +
  + 
  +    return err;
  +}
   
   
   
  
  
  
  1.2       +26 -1     xml-xerces/c/src/util/Transcoders/Iconv400/Iconv400TransService.hpp
  
  Index: Iconv400TransService.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/util/Transcoders/Iconv400/Iconv400TransService.hpp,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Iconv400TransService.hpp	2000/02/10 18:08:28	1.1
  +++ Iconv400TransService.hpp	2000/09/28 22:42:45	1.2
  @@ -55,10 +55,7 @@
    */
   
   /**
  - * $Log: Iconv400TransService.hpp,v $
  - * Revision 1.1  2000/02/10 18:08:28  abagchi
  - * Initial checkin
  - *
  + * $Id: Iconv400TransService.hpp,v 1.2 2000/09/28 22:42:45 aruna1 Exp $
    */
   
   #ifndef ICONV400TRANSSERVICE_HPP
  @@ -152,7 +149,31 @@
       );
       ~Iconv400Transcoder();
   
  +    virtual unsigned int transcodeFrom
  +    (
  +        const   XMLByte* const          srcData
  +        , const unsigned int            srcCount
  +        ,       XMLCh* const            toFill
  +        , const unsigned int            maxChars
  +        ,       unsigned int&           bytesEaten
  +        ,       unsigned char* const    charSizes
  +    );
  +
  +    virtual unsigned int transcodeTo
  +    (
  +        const   XMLCh* const    srcData
  +        , const unsigned int    srcCount
  +        ,       XMLByte* const  toFill
  +        , const unsigned int    maxBytes
  +        ,       unsigned int&   charsEaten
  +        , const UnRepOpts       options
  +    );
   
  +    virtual bool canTranscodeTo
  +    (
  +        const   unsigned int    toCheck
  +    )   const;
  +
       // -----------------------------------------------------------------------
       //  Implementation of the virtual transcoder interface
       // -----------------------------------------------------------------------
  @@ -173,6 +194,7 @@
           ,       unsigned int&           bytesEaten
           ,       unsigned char* const    charSizes
       );
  +
   
   
   private :