One very commonly asked one is:

How do I transcode to/from something besides the local code page?

XMLString::transcode() will transcode from XMLCh to the local code page, and
other APIs which take a char* assume that the source text is in the local
code page. If this is not true, you must transcode the text yourself. You
can do this using local transcoding support on your OS, such as Iconv on
Unix or or IBM's ICU package. However, if your transcoding needs are simple,
you can achieve some better portability by using the Xerces parser's
transcoder wrappers. You get a transcoder like this:

1. Call XMLPlatformUtils::fgTransServer->MakeNewTranscoderFor() and provide
the name of the encoding you wish to create a transcoder for. This will
return a transcoder to you, which you own and must delete when you are
through with it.

* You must provide a maximum block size that you will pass to the transcoder
at one time, and you must blocks of characters of this count or smaller when
you do your transcoding. The reason for this is that this is really an
internal API and is used by the parser itself to do transcoding. The parser
always does transcoding in known block sizes, and this allows transcoders to
be much more efficient for internal use since it knows the max size it will
ever have to deal with and can set itself up for that internally. In
general, you should stick to block sizes in the 4 to 64K range.

2. The returned transcoder is something derived from XMLTranscoder, so they
are all returned to you via that interface.

3. This object is really just a wrapper around the underlying transcoding
system actually in use by your version of Xerces, and does whatever is
necessary to handle differences between the XMLCh representation and the
representation uesd by that underying transocding system.

4. The transcoder object has two primary APIs, transcodeFrom() and
transcodeTo(). These transcode between the XMLCh format and the encoding you
indicated.

5. These APIs will transcode as much of the source data as will fit into the
outgoing buffer you provide. They will tell you how much of the source they
ate and how much of the target they filled. You can use this information to
continue the process until all source is consumed.

6. char* data is always dealt with in terms of bytes, and XMLCh data is
always dealt with in terms of characters. Don't mix up which you are dealing
with or you will not get the correct results, since many encodings don't
have a one to one relationship of characters to bytes.

7. When transcoding from XMLCh to the target encoding, the transcodeTo()
method provides an 'unrepresentable flag' parameter, which tells the
transcoder how to deal with an XMLCh code point that cannot be converted
legally to the target encoding, which can easily happen since XMLCh is
Unicode and can represent thousands of code points. The options are to use a
default replacement character (which the underlying transcoding service will
choose, and which is guaranteed to be legal for the target encoding), or to
throw an exception.


--------------
Dean Roddey
Software Geek Extraordinaire
Portal, Inc
[EMAIL PROTECTED]



-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, May 30, 2001 7:58 AM
To: [EMAIL PROTECTED]
Subject: It's time to update the FAQ!


Hi, there,

      I am now updating the FAQ with some schema-related quick questiones.
      If you have any Xerces-C FAQ wanna to get in, it's the opportunity
for us
     to gather the information.

      If  you have anything for the migration guide, programming guide,
     build instruction or areas not mentioned here, please let me know as
well
     since I am now consolidating updates to all documentation for the
Xerces 1.5.

     Thanks!


Regards,

Peiyong Zhang
____________________________________________
XML Parsers Development
IBM Toronto Laboratory email: [EMAIL PROTECTED]
Phone: (416)448-4088; Fax: (416)448-4414; T/L: 778-4088


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

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

Reply via email to