dbertoni    01/09/14 13:03:06

  Modified:    c/src/PlatformSupport XalanToXercesTranscoderWrapper.cpp
                        XalanToXercesTranscoderWrapper.hpp
                        XalanTranscodingServices.hpp
                        XalanUTF16Transcoder.cpp XalanUTF16Transcoder.hpp
  Log:
  Added support for transcoding to UTF-16.
  
  Revision  Changes    Path
  1.3       +34 -0     
xml-xalan/c/src/PlatformSupport/XalanToXercesTranscoderWrapper.cpp
  
  Index: XalanToXercesTranscoderWrapper.cpp
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/c/src/PlatformSupport/XalanToXercesTranscoderWrapper.cpp,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- XalanToXercesTranscoderWrapper.cpp        2000/10/04 18:40:34     1.2
  +++ XalanToXercesTranscoderWrapper.cpp        2001/09/14 20:03:06     1.3
  @@ -116,3 +116,37 @@
   
        return theCode;
   }
  +
  +
  +
  +XalanToXercesTranscoderWrapper::eCode
  +XalanToXercesTranscoderWrapper::transcode(
  +                     const XalanXMLByte*             theSourceData,
  +                     unsigned int                    theSourceCount,
  +                     XalanDOMChar*                   theTarget,
  +                     unsigned int                    theTargetSize,
  +                     unsigned int&                   theSourceCharsTranscoded,
  +                     unsigned int&                   theTargetBytesUsed,
  +                     unsigned char*                  theCharSizes)
  +{
  +     eCode   theCode = XalanTranscodingServices::OK;
  +
  +     try
  +     {
  +             theTargetBytesUsed = m_transcoder->transcodeFrom(
  +                     theSourceData,
  +                     theSourceCount,
  +                     theTarget,
  +                     theTargetSize,
  +                     theSourceCharsTranscoded,
  +                     theCharSizes);
  +     }
  +     catch(const XMLException&)
  +     {
  +             theSourceCharsTranscoded = 0;
  +             theTargetBytesUsed = 0;
  +             theCode = XalanTranscodingServices::InternalFailure;
  +     }
  +
  +     return theCode;
  +}
  
  
  
  1.2       +10 -0     
xml-xalan/c/src/PlatformSupport/XalanToXercesTranscoderWrapper.hpp
  
  Index: XalanToXercesTranscoderWrapper.hpp
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/c/src/PlatformSupport/XalanToXercesTranscoderWrapper.hpp,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- XalanToXercesTranscoderWrapper.hpp        2000/09/27 16:24:12     1.1
  +++ XalanToXercesTranscoderWrapper.hpp        2001/09/14 20:03:06     1.2
  @@ -92,6 +92,16 @@
                        unsigned int&                   theSourceCharsTranscoded,
                        unsigned int&                   theTargetBytesUsed);
   
  +     virtual eCode
  +     transcode(
  +                     const XalanXMLByte*             theSourceData,
  +                     unsigned int                    theSourceCount,
  +                     XalanDOMChar*                   theTarget,
  +                     unsigned int                    theTargetSize,
  +                     unsigned int&                   theSourceCharsTranscoded,
  +                     unsigned int&                   theTargetBytesUsed,
  +                     unsigned char*                  theCharSizes);
  +
   private:
   
        // Not implemented...
  
  
  
  1.5       +24 -0     xml-xalan/c/src/PlatformSupport/XalanTranscodingServices.hpp
  
  Index: XalanTranscodingServices.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/PlatformSupport/XalanTranscodingServices.hpp,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- XalanTranscodingServices.hpp      2001/02/09 01:37:22     1.4
  +++ XalanTranscodingServices.hpp      2001/09/14 20:03:06     1.5
  @@ -319,6 +319,30 @@
                        unsigned int&                   theSourceCharsTranscoded,
                        unsigned int&                   theTargetBytesUsed) = 0;
   
  +     /**
  +      * Transcode data from the transcoder's encoding to UTF-16.  If successfull,
  +      * theResult will be set to OK.  If not, it will be set to one of the other
  +      * codes.
  +      *
  +      * @param theSourceData The source data to transcode
  +      * @param theSourceCount The length of the source data.
  +      * @param theTarget The target array for storing the transcoded data.
  +      * @param theTargetSize The number of characters that can be stored in the 
target.
  +      * @param theSourceCharsTranscoded The count of the source characters that 
were transcoded.
  +      * @param theTargetBytesUsed The number of characters stored in the target 
array
  +      * @param theCharSizes For each character in theTarget, the number of 
characters consumed from theSourceData.
  +      * @return The result code.
  +      */
  +     virtual eCode
  +     transcode(
  +                     const XalanXMLByte*             theSourceData,
  +                     unsigned int                    theSourceCount,
  +                     XalanDOMChar*                   theTarget,
  +                     unsigned int                    theTargetSize,
  +                     unsigned int&                   theSourceCharsTranscoded,
  +                     unsigned int&                   theTargetBytesUsed,
  +                     unsigned char*                  theCharSizes) = 0;
  +
   private:
   
        // Not implemented...
  
  
  
  1.3       +47 -0     xml-xalan/c/src/PlatformSupport/XalanUTF16Transcoder.cpp
  
  Index: XalanUTF16Transcoder.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/PlatformSupport/XalanUTF16Transcoder.cpp,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- XalanUTF16Transcoder.cpp  2001/01/08 18:15:07     1.2
  +++ XalanUTF16Transcoder.cpp  2001/09/14 20:03:06     1.3
  @@ -119,3 +119,50 @@
   
        return XalanTranscodingServices::OK;
   }
  +
  +
  +
  +XalanUTF16Transcoder::eCode
  +XalanUTF16Transcoder::transcode(
  +                     const XalanXMLByte*             theSourceData,
  +                     unsigned int                    theSourceCount,
  +                     XalanDOMChar*                   theTarget,
  +                     unsigned int                    theTargetSize,
  +                     unsigned int&                   theSourceCharsTranscoded,
  +                     unsigned int&                   theTargetBytesUsed,
  +                     unsigned char*                  theCharSizes)
  +{
  +     unsigned int    theSourceEaten = 0;
  +     unsigned int    theTargetPosition = 0;
  +
  +     while(theSourceEaten < theSourceCount)
  +     {
  +             // Swap bytes to big endian...
  +             if (theTargetPosition + 1 >= theTargetSize)
  +             {
  +                     break;
  +             }
  +             else
  +             {
  +#if defined(XALAN_LITLE_ENDIAN)
  +                     const XalanXMLByte      theLowByte = 
theSourceData[theSourceCount++];
  +                     const XalanXMLByte      theHighByte = 
theSourceData[theSourceCount++];
  +#elif defined(XALAN_BIG_ENDIAN)
  +                     const XalanXMLByte      theHighByte = 
theSourceData[theSourceCount++];
  +                     const XalanXMLByte      theLowByte = 
theSourceData[theSourceCount++];
  +#else
  +#error The platform must define the byte order!
  +#endif
  +
  +                     theTarget[theTargetPosition++] = XalanDOMChar((theHighByte << 
8) | theLowByte);
  +
  +                     *theCharSizes++ = 2;
  +             }
  +     }
  +
  +     theSourceCharsTranscoded = theSourceEaten;
  +
  +     theTargetBytesUsed = theTargetPosition;
  +
  +     return XalanTranscodingServices::OK;
  +}
  
  
  
  1.2       +23 -2     xml-xalan/c/src/PlatformSupport/XalanUTF16Transcoder.hpp
  
  Index: XalanUTF16Transcoder.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/PlatformSupport/XalanUTF16Transcoder.hpp,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- XalanUTF16Transcoder.hpp  2000/09/27 16:24:12     1.1
  +++ XalanUTF16Transcoder.hpp  2001/09/14 20:03:06     1.2
  @@ -80,8 +80,7 @@
        ~XalanUTF16Transcoder();
   
        /**
  -      * Transcode data from UTF-16 to UTF-16.  Used for the time being, because, on 
some
  -      * platforms, we store UTF-16 in 4-byte wchar_t.
  +      * Transcode data from UTF-16 to UTF-16.
         *
         * @param theSourceData The source data to transcode
         * @param theSourceCount The length of the source data.
  @@ -100,6 +99,28 @@
                        unsigned int                    theTargetSize,
                        unsigned int&                   theSourceCharsTranscoded,
                        unsigned int&                   theTargetBytesUsed);
  +
  +     /**
  +      * Transcode data from UTF-16 to UTF-16.
  +      *
  +      * @param theSourceData The source data to transcode
  +      * @param theSourceCount The length of the source data.
  +      * @param theResult The error code, if any.
  +      * @param theTarget The target array for storing the transcoded data.
  +      * @param theTargetSize The number of characters that can be stored in the 
target.
  +      * @param theSourceCharsTranscoded The count of the source characters that 
were transcoded.
  +      * @param theTargetBytesUsed The number of characters stored in the target 
array
  +      * @return The result code.
  +      */
  +     virtual eCode
  +     transcode(
  +                     const XalanXMLByte*             theSourceData,
  +                     unsigned int                    theSourceCount,
  +                     XalanDOMChar*                   theTarget,
  +                     unsigned int                    theTargetSize,
  +                     unsigned int&                   theSourceCharsTranscoded,
  +                     unsigned int&                   theTargetBytesUsed,
  +                     unsigned char*                  theCharSizes);
   
   private:
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to