xerces-c-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alberto Massari <amass...@progress.com>
Subject Re: DOMPrint
Date Tue, 13 Apr 2004 09:20:55 GMT
At 03.32 12/04/2004 -0700, P M S Prakash wrote:
>Hi Alberto,
>
>Yes, the original XML document had UTF-16 encoding.
>After changing it to appropriate encoding, it worked.
>
>Also, in my application, I am setting the encoding
>using setEncoding, by determining the character set of
>the local system. The following is the sample code. Is
>it the right way to determine if it is a UTF-8,
>ISO8859-1 or EUC-JP? Or are there any APIs xerces
>provide to do this?

AFAIK, Xerces doesn't provide an API to get the encoding associated with 
the local code page of the system; it can only transcode Unicode strings 
into that code page (XMLString::transcode). So, if on your system, 
nl_langinfo gives you a correct encoding, that's the way to go.

Alberto


>     // Get the current character set
>     char *nlinfo;
>     nlinfo=nl_langinfo(CODESET);
>
>
>     XMLCh encStr[100];
>     XMLString::transcode(nlinfo, encStr, 99);
>
>     theSerializer_p->setEncoding(encStr);
>     theSerializer_p->writeNode(myFormatTarget,*doc);
>
>Thanks
>Regards
>Prakash
>--- Alberto Massari <amassari@progress.com> wrote:
> > Did you specify an encoding when you ran the
> > program? If you specified a
> > Unicode encoding like UCS-2 or UTF-16, the
> > getRawBuffer() method will
> > return a pointer to an XMLCh* buffer, not a char*.
> >
> > Alberto
> >
> > At 04.31 08/04/2004 -0700, P M S Prakash wrote:
> > >Hi Alberto,
> > >
> > >I just changed the DOMPrint.cpp sample to use
> > >MemBufFormatTarget instead of XMLFormatTarget. When
> > I
> > >did getRawBuffer() and casted to char *, it is just
> > >printing single letter. But, when I print the
> > length
> > >of the MemBufFormatTarget object, it is printing
> > >correctly.
> > >
> > >Do you have any idea why it is returning single
> > >character?
> > >
> > >Regards
> > >Prakash
> > >
> > >__________________________________
> > >Do you Yahoo!?
> > >Yahoo! Small Business $15K Web Design Giveaway
> > >http://promotions.yahoo.com/design_giveaway//*
> > >  * The Apache Software License, Version 1.1
> > >  *
> > >  * Copyright (c) 2002 The Apache Software
> > Foundation.  All rights
> > >  * reserved.
> > >  *
> > >  * Redistribution and use in source and binary
> > forms, with or without
> > >  * modification, are permitted provided that the
> > following conditions
> > >  * are met:
> > >  *
> > >  * 1. Redistributions of source code must retain
> > the above copyright
> > >  *    notice, this list of conditions and the
> > following disclaimer.
> > >  *
> > >  * 2. Redistributions in binary form must
> > reproduce the above copyright
> > >  *    notice, this list of conditions and the
> > following disclaimer in
> > >  *    the documentation and/or other materials
> > provided with the
> > >  *    distribution.
> > >  *
> > >  * 3. The end-user documentation included with the
> > redistribution,
> > >  *    if any, must include the following
> > acknowledgment:
> > >  *       "This product includes software developed
> > by the
> > >  *        Apache Software Foundation
> > (http://www.apache.org/)."
> > >  *    Alternately, this acknowledgment may appear
> > in the software itself,
> > >  *    if and wherever such third-party
> > acknowledgments normally appear.
> > >  *
> > >  * 4. The names "Xerces" and "Apache Software
> > Foundation" must
> > >  *    not be used to endorse or promote products
> > derived from this
> > >  *    software without prior written permission.
> > For written
> > >  *    permission, please contact
> > apache\@apache.org.
> > >  *
> > >  * 5. Products derived from this software may not
> > be called "Apache",
> > >  *    nor may "Apache" appear in their name,
> > without prior written
> > >  *    permission of the Apache Software
> > Foundation.
> > >  *
> > >  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY
> > EXPRESSED OR IMPLIED
> > >  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
> > IMPLIED WARRANTIES
> > >  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
> > PURPOSE ARE
> > >  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE
> > SOFTWARE FOUNDATION OR
> > >  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
> > INDIRECT, INCIDENTAL,
> > >  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
> > (INCLUDING, BUT NOT
> > >  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
> > SERVICES; LOSS OF
> > >  * USE, DATA, OR PROFITS; OR BUSINESS
> > INTERRUPTION) HOWEVER CAUSED AND
> > >  * ON ANY THEORY OF LIABILITY, WHETHER IN
> > CONTRACT, STRICT LIABILITY,
> > >  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
> > ARISING IN ANY WAY OUT
> > >  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
> > THE POSSIBILITY OF
> > >  * SUCH DAMAGE.
> > >  *
> >
>====================================================================
> > >  *
> > >  * This software consists of voluntary
> > contributions made by many
> > >  * individuals on behalf of the Apache Software
> > Foundation, and was
> > >  * originally based on software copyright (c)
> > 1999, International
> > >  * Business Machines, Inc., http://www.ibm.com .
> > For more information
> > >  * on the Apache Software Foundation, please see
> > >  * <http://www.apache.org/>.
> > >  */
> > >
> > >/*
> > >  * $Id: DOMPrint.cpp,v 1.58 2003/05/30 09:36:35
> > gareth Exp $
> > >  */
> > >
> > >//
> >
>---------------------------------------------------------------------------
> > >//  This sample program invokes the XercesDOMParser
> > to build a DOM tree for
> > >//  the specified input file. It then invokes
> > DOMWriter::writeNode() to
> > >//  serialize the resultant DOM tree back to XML
> > stream.
> > >//
> > >//  Note:
> > >//  Application needs to provide its own
> > implementation of
> > >//                 DOMErrorHandler (in this sample,
> > the DOMPrintErrorHandler),
> > >//                 if it would like to receive
> > notification from the
> > >serializer
> > >//                 in the case any error occurs
> > during the serialization.
> > >//
> > >//  Application needs to provide its own
> > implementation of
> > >//                 DOMWriterFilter (in this sample,
> > the DOMPrintFilter),
> > >//                 if it would like to filter out
> > certain part of the DOM
> > >//                 representation, but must be
> > aware that thus may render the
> > >//                 resultant XML stream invalid.
> > >//
> > >//  Application may choose any combination of
> > characters as the
> > >//                 end of line sequence to be used
> > in the resultant XML
> > >stream,
> > >//                 but must be aware that thus may
> > render the resultant XML
> > >//                 stream ill formed.
> > >//
> > >//  Application may choose a particular encoding
> > name in which
> > >//                 the output XML stream would be,
> > but must be aware that if
> > >//                 characters, unrepresentable in
> > the encoding specified,
> > >appearing
> > >//                 in markups, may force the
> > serializer to terminate
> > >serialization
> > >//                 prematurely, and thus no
> > complete serialization would
> > >be done.
> > >//
> > >//  Application shall query the serializer first,
> > before set any
> > >//           feature/mode(true, false), or be ready
> > to catch exception if this
> > >//           feature/mode is not supported by the
> > serializer.
> > >//
> > >//  Application needs to clean up the filter, error
> > handler and
> > >//                 format target objects created
> > for the serialization.
> > >//
> > >//   Limitations:
> > >//      1.  The encoding="xxx" clause in the XML
> > header should reflect
> > >//          the system local code page, but does
> > not.
> > >//      2.  Cases where the XML data contains
> > characters that can not
> > >//          be represented in the system local code
> > page are not handled.
> >
>=== message truncated ===
>
>
>__________________________________
>Do you Yahoo!?
>Yahoo! Tax Center - File online by April 15th
>http://taxes.yahoo.com/filing.html
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
>For additional commands, e-mail: xerces-c-dev-help@xml.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


Mime
View raw message