Jason, thanks for the help.

1. Unfortunately, I'm getting an unhandled exception (access violation)
somewhere inside the call to transcodeTo().  Any idea why this would happen?

2. I'm also a bit fuzzy about the value of UTF8_MAXLEN.  Would this normally
be 4 or so?


I'm using xerces 1.2, hope that's ok.

thanks!

- Brendan




> Here's a bit of C-ish typemap code that does it. Note that $source is
> the XMLCh* input string, and UTF8_TRANSCODER is a global variable set
> to a pre-allocated transcoder for UTF-8.
>
>   unsigned int charsEaten = 0;
>   int length  = XMLString::stringLen($source);      // string length
>   XMLByte* res = new XMLByte[length * UTF8_MAXLEN];          //
> output string
>   unsigned int total_chars =
>     UTF8_TRANSCODER->transcodeTo((const XMLCh*) $source,
>                                  (unsigned int) length,
>                                  (XMLByte*) res,
>                                  (unsigned int) length*UTF8_MAXLEN,
>                                  charsEaten,
>                                  XMLTranscoder::UnRep_Throw
>                                  );
>   res[total_chars] = '\0';
>
> Here's the code that allocates the transcoder:
>
> static XMLCh* UTF8_ENCODING = NULL;
> static XMLTranscoder* UTF8_TRANSCODER  = NULL;
>     XMLTransService::Codes failReason;
>     XMLPlatformUtils::Initialize(); // first we must create the
> transservice
>     UTF8_ENCODING = XMLString::transcode("UTF-8");
>     UTF8_TRANSCODER =
>
> XMLPlatformUtils::fgTransService->makeNewTranscoderFor(UTF8_ENCODING,
>                                                              failReason,
>                                                              1024);
>     if (! UTF8_TRANSCODER) {
>       croak("ERROR: XML::Xerces: INIT: Could not create UTF-8
> transcoder");
>     }
>
> HTH,
> jas.
>
> ---------------------------------------------------------------------
> 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