You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by Simon Fell <xm...@zaks.demon.co.uk> on 2001/03/31 22:52:05 UTC

transcodeTo sample ?

Platform : W2K / VC6 / Xerces-C 1.3

Does anyone have a decent sample of using transcodeTo ?, I have a
UTF-16 string i'm trying to transcode to UTF-8, but i'm a little
unsure of the buffer management on the destination buffer. I allocate
a buffer, and if its not big enough, it looks like charEaten will be
less than the source string length. So, i re-allocate the buffer
making it bigger, how do i pick up the transcoding where i left off ?,
do i past the start of the buffer back in, or do i need to pass in
where it got to last time ?

It also looks like after calling makeNewTranscoderFor that the
resValue is not getting set.


and on a completely different topic, I'm working on a SOAP server (XML
over HTTP), this requires conformance to RFC 2376, which requires that
the charset indicated in the content-type header be the deciding
factor for the encoding of the XML, and this should override any xml
decl. Is there anyway to do this in Xerces other than re-writing the
xml decl ?

TIA
Simon

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


Re: transcodeTo sample ?

Posted by kaoruAngel <cl...@athenet.net>.
I'm afraid the word of Dean Roddey _is_ your documentation ;)

He has, however, seemed to have answered every question regarding
transcoding on this list as well as IBM's discussion board, regardless of
redundancy. So, although I could not possibly speak for Dean, I must say
that, for now at least, you should feel in good hands.

Surely this is not a replacement for solid documentation and should not be
so easily accepted, but I am hopeful that the developers are aware of the
current lack, and that with the next release will be further documentation.
Perhaps that is the wrong thing to expect as documentation usually lags
_behind_ with further development in most projects I know! : p

I am only new to XML and this list. So, hopefully someone else can give us a
better answer.


- kaoruAngel


----- Original Message -----
From: "John Snelson" <jp...@decisionsoft.com>
To: <xe...@xml.apache.org>
Sent: Monday, April 02, 2001 5:27 AM
Subject: Re: transcodeTo sample ?


> Talking of transcoding, where are there docs or examples of how to use
> the transcoder classes in Xerces. The class documentation has no
> comments in at all.
>
> John
>
> Dean Roddey wrote:
> >
> >  The best way to deal with this kind of thing is just to allow the
buffer to
> > expand as required. If you get a failure because its too small, increase
it
> > to what was indicated as required, plus some extra slop. Pretty quickly,
in
> > most cases, it will get to the high water mark and just stay there. Let
it
> > go when done with that round of transcoding. But, if it fails due to too
> > small a buffer, its probably best to just start over on that particular
bit
> > unless you are doing bulk trancoding of whole files at time or
something.
> >
> > If you are just bulk transcoding, then take what you got transcoded and
copy
> > it somewhere else, then call back in using the bytes eaten count to skip
> > forward in the source buffer and start transcoding from there (being
sure to
> > adjust the source size by the number that you ate on that round. So just
do
> > this in a loop until you've transcoded everything. If you look around in
> > some of the parser code, like XMLReader and such, you'll see examples of
> > this kind of thing being done.
> >
> > --------------------------
> > Dean Roddey
> > The CIDLib C++ Frameworks
> > Charmed Quark Software
> > droddey@charmedquark.com
> > http://www.charmedquark.com
> >
> > "I'm not sure how I feel about ambivalence"
> >
> > ----- Original Message -----
> > From: "Simon Fell" <xm...@zaks.demon.co.uk>
> > To: <xe...@xml.apache.org>
> > Sent: Saturday, March 31, 2001 12:52 PM
> > Subject: transcodeTo sample ?
> >
> > > Platform : W2K / VC6 / Xerces-C 1.3
> > >
> > > Does anyone have a decent sample of using transcodeTo ?, I have a
> > > UTF-16 string i'm trying to transcode to UTF-8, but i'm a little
> > > unsure of the buffer management on the destination buffer. I allocate
> > > a buffer, and if its not big enough, it looks like charEaten will be
> > > less than the source string length. So, i re-allocate the buffer
> > > making it bigger, how do i pick up the transcoding where i left off ?,
> > > do i past the start of the buffer back in, or do i need to pass in
> > > where it got to last time ?
> > >
> > > It also looks like after calling makeNewTranscoderFor that the
> > > resValue is not getting set.
> > >
> > >
> > > and on a completely different topic, I'm working on a SOAP server (XML
> > > over HTTP), this requires conformance to RFC 2376, which requires that
> > > the charset indicated in the content-type header be the deciding
> > > factor for the encoding of the XML, and this should override any xml
> > > decl. Is there anyway to do this in Xerces other than re-writing the
> > > xml decl ?
> > >
> > > TIA
> > > Simon
> > >
> > > ---------------------------------------------------------------------
> > > 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
>
> --
> John Snelson, Software Engineer       DecisionSoft Ltd.
> Telephone: +44-1865-203192            http://www.decisionsoft.com
>
> ---------------------------------------------------------------------
> 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


Re: transcodeTo sample ?

Posted by John Snelson <jp...@decisionsoft.com>.
Talking of transcoding, where are there docs or examples of how to use
the transcoder classes in Xerces. The class documentation has no
comments in at all.

John

Dean Roddey wrote:
> 
>  The best way to deal with this kind of thing is just to allow the buffer to
> expand as required. If you get a failure because its too small, increase it
> to what was indicated as required, plus some extra slop. Pretty quickly, in
> most cases, it will get to the high water mark and just stay there. Let it
> go when done with that round of transcoding. But, if it fails due to too
> small a buffer, its probably best to just start over on that particular bit
> unless you are doing bulk trancoding of whole files at time or something.
> 
> If you are just bulk transcoding, then take what you got transcoded and copy
> it somewhere else, then call back in using the bytes eaten count to skip
> forward in the source buffer and start transcoding from there (being sure to
> adjust the source size by the number that you ate on that round. So just do
> this in a loop until you've transcoded everything. If you look around in
> some of the parser code, like XMLReader and such, you'll see examples of
> this kind of thing being done.
> 
> --------------------------
> Dean Roddey
> The CIDLib C++ Frameworks
> Charmed Quark Software
> droddey@charmedquark.com
> http://www.charmedquark.com
> 
> "I'm not sure how I feel about ambivalence"
> 
> ----- Original Message -----
> From: "Simon Fell" <xm...@zaks.demon.co.uk>
> To: <xe...@xml.apache.org>
> Sent: Saturday, March 31, 2001 12:52 PM
> Subject: transcodeTo sample ?
> 
> > Platform : W2K / VC6 / Xerces-C 1.3
> >
> > Does anyone have a decent sample of using transcodeTo ?, I have a
> > UTF-16 string i'm trying to transcode to UTF-8, but i'm a little
> > unsure of the buffer management on the destination buffer. I allocate
> > a buffer, and if its not big enough, it looks like charEaten will be
> > less than the source string length. So, i re-allocate the buffer
> > making it bigger, how do i pick up the transcoding where i left off ?,
> > do i past the start of the buffer back in, or do i need to pass in
> > where it got to last time ?
> >
> > It also looks like after calling makeNewTranscoderFor that the
> > resValue is not getting set.
> >
> >
> > and on a completely different topic, I'm working on a SOAP server (XML
> > over HTTP), this requires conformance to RFC 2376, which requires that
> > the charset indicated in the content-type header be the deciding
> > factor for the encoding of the XML, and this should override any xml
> > decl. Is there anyway to do this in Xerces other than re-writing the
> > xml decl ?
> >
> > TIA
> > Simon
> >
> > ---------------------------------------------------------------------
> > 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

-- 
John Snelson, Software Engineer       DecisionSoft Ltd.
Telephone: +44-1865-203192            http://www.decisionsoft.com

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


Re: transcodeTo sample ?

Posted by Dean Roddey <dr...@charmedquark.com>.
 The best way to deal with this kind of thing is just to allow the buffer to
expand as required. If you get a failure because its too small, increase it
to what was indicated as required, plus some extra slop. Pretty quickly, in
most cases, it will get to the high water mark and just stay there. Let it
go when done with that round of transcoding. But, if it fails due to too
small a buffer, its probably best to just start over on that particular bit
unless you are doing bulk trancoding of whole files at time or something.

If you are just bulk transcoding, then take what you got transcoded and copy
it somewhere else, then call back in using the bytes eaten count to skip
forward in the source buffer and start transcoding from there (being sure to
adjust the source size by the number that you ate on that round. So just do
this in a loop until you've transcoded everything. If you look around in
some of the parser code, like XMLReader and such, you'll see examples of
this kind of thing being done.

--------------------------
Dean Roddey
The CIDLib C++ Frameworks
Charmed Quark Software
droddey@charmedquark.com
http://www.charmedquark.com

"I'm not sure how I feel about ambivalence"


----- Original Message -----
From: "Simon Fell" <xm...@zaks.demon.co.uk>
To: <xe...@xml.apache.org>
Sent: Saturday, March 31, 2001 12:52 PM
Subject: transcodeTo sample ?


> Platform : W2K / VC6 / Xerces-C 1.3
>
> Does anyone have a decent sample of using transcodeTo ?, I have a
> UTF-16 string i'm trying to transcode to UTF-8, but i'm a little
> unsure of the buffer management on the destination buffer. I allocate
> a buffer, and if its not big enough, it looks like charEaten will be
> less than the source string length. So, i re-allocate the buffer
> making it bigger, how do i pick up the transcoding where i left off ?,
> do i past the start of the buffer back in, or do i need to pass in
> where it got to last time ?
>
> It also looks like after calling makeNewTranscoderFor that the
> resValue is not getting set.
>
>
> and on a completely different topic, I'm working on a SOAP server (XML
> over HTTP), this requires conformance to RFC 2376, which requires that
> the charset indicated in the content-type header be the deciding
> factor for the encoding of the XML, and this should override any xml
> decl. Is there anyway to do this in Xerces other than re-writing the
> xml decl ?
>
> TIA
> Simon
>
> ---------------------------------------------------------------------
> 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