peiyongz    2003/01/28 10:32:33

  Modified:    c/src/xercesc/framework XMLRecognizer.cpp XMLFormatter.hpp
                        XMLFormatter.cpp
  Log:
  Bug#13694: Allow Xerces to write the BOM to XML files
  
  Revision  Changes    Path
  1.5       +8 -5      xml-xerces/c/src/xercesc/framework/XMLRecognizer.cpp
  
  Index: XMLRecognizer.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/framework/XMLRecognizer.cpp,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- XMLRecognizer.cpp 25 Nov 2002 21:23:31 -0000      1.4
  +++ XMLRecognizer.cpp 28 Jan 2003 18:32:33 -0000      1.5
  @@ -151,12 +151,15 @@
           return UTF_8;
   
       //
  -    //  We know its at least two bytes, so lets check for a UTF-16 BOM. That
  -    //  is quick to check and enough to identify two major encodings.
  +    //  Checking BOM for UCS-4BE, UCS-4LE, UTF-16BE and UTF-16LE
       //
  -    if ((rawBuffer[0] == 0xFE) && (rawBuffer[1] == 0xFF))
  +    if ((rawBuffer[0] == 0x00) && (rawBuffer[1] == 0x00) && (rawBuffer[2] == 0xFE) 
&& (rawBuffer[3] == 0xFF))
  +        return UCS_4B;
  +    else if ((rawBuffer[0] == 0xFF) && (rawBuffer[1] == 0xFE) && (rawBuffer[2] == 
0x00) && (rawBuffer[3] == 0x00))
  +        return UCS_4L;
  +    else if ((rawBuffer[0] == 0xFE) && (rawBuffer[1] == 0xFF) && (rawBuffer[2] == 
0x00) && (rawBuffer[3] != 0x00))
           return UTF_16B;
  -    else if ((rawBuffer[0] == 0xFF) && (rawBuffer[1] == 0xFE))
  +    else if ((rawBuffer[0] == 0xFF) && (rawBuffer[1] == 0xFE) && (rawBuffer[2] != 
0x00) && (rawBuffer[3] == 0x00))
           return UTF_16L;
   
       //
  
  
  
  1.6       +7 -0      xml-xerces/c/src/xercesc/framework/XMLFormatter.hpp
  
  Index: XMLFormatter.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/framework/XMLFormatter.hpp,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- XMLFormatter.hpp  24 Jan 2003 20:20:22 -0000      1.5
  +++ XMLFormatter.hpp  28 Jan 2003 18:32:33 -0000      1.6
  @@ -56,6 +56,9 @@
   
   /*
    * $Log$
  + * Revision 1.6  2003/01/28 18:32:33  peiyongz
  + * Bug#13694: Allow Xerces to write the BOM to XML files
  + *
    * Revision 1.5  2003/01/24 20:20:22  tng
    * Add method flush to XMLFormatTarget
    *
  @@ -307,6 +310,10 @@
       (
           const   XMLCh           toFormat
       );
  +
  +    void XMLFormatter::writeBOM(const XMLByte* const toFormat
  +                              , const unsigned int   count);
  +
       //@}
   
       // -----------------------------------------------------------------------
  
  
  
  1.7       +11 -2     xml-xerces/c/src/xercesc/framework/XMLFormatter.cpp
  
  Index: XMLFormatter.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/framework/XMLFormatter.cpp,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- XMLFormatter.cpp  24 Jan 2003 20:24:28 -0000      1.6
  +++ XMLFormatter.cpp  28 Jan 2003 18:32:33 -0000      1.7
  @@ -460,7 +460,16 @@
       return *this;
   }
   
  -
  +/**
  + * the parameter, count, is needed since stringLen()
  + * does not work on a BOM like "0xFE0xFF0x000x00" or
  + * "0x000x000xFF0xFE"
  + **/
  +void XMLFormatter::writeBOM(const XMLByte* const toFormat
  +                          , const unsigned int   count)
  +{
  +    fTarget->writeChars(toFormat, count, this);    
  +}
   
   // ---------------------------------------------------------------------------
   //  XMLFormatter: Private helper methods
  
  
  

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

Reply via email to