hi,
with the changes u have suggested, i am still getting this stack trace at
the stmt
t->transcodeTo(s2, (unsigned int)(args[0]->str()).length(), s1, 200,
charsEaten, XMLTranscoder::UnRep_Throw);
#1 0x098c4f91 in xalanc_1_10::XPathEnvSupportDefault::extFunction ()
#2 0x09843919 in xalanc_1_10::XSLTProcessorEnvSupportDefault::extFunction
()
#3 0x097e7c7e in
xalanc_1_10::StylesheetExecutionContextDefault::extFunction
()
#4 0x098ba925 in xalanc_1_10::XPath::runExtFunction ()
#5 0x098bb462 in xalanc_1_10::XPath::executeMore ()
#6 0x0993f9a3 in xalanc_1_10::ElemWithParam::startElement ()
#7 0x0993913c in xalanc_1_10::ElemTemplateElement::execute ()
#8 0x0981c272 in xalanc_1_10::StylesheetRoot::process ()
#9 0x09833753 in xalanc_1_10::XSLTEngineImpl::process ()
#10 0x097630d4 in xalanc_1_10::XalanTransformer::doTransform ()
#11 0x09763410 in xalanc_1_10::XalanTransformer::transform ()
yes the transcoder pointer is null.what am i doing wrong here?
thanks.
On Sun, Oct 12, 2008 at 12:04 AM, David Bertoni <[EMAIL PROTECTED]> wrote:
> souri datta wrote:
>
>> Thanks David for all the replies.
>> I am using the following code :
>> XMLByte *s1;
>> const XMLCh *s2 = (args[0]->str()).c_str();
>> unsigned int charsEaten;
>> XMLTransService::Codes code;
>> try{
>>
>> CdxNote<<"(args[0]->str()="<<(args[0]->str())<<CdxEndl;
>> XMLTranscoder* t =
>> XMLPlatformUtils::fgTransService->makeNewTranscoderFor((const XMLCh*)
>> "UTF-32", code, (unsigned int) 16*1024);
>>
> I can't believe this code actually works. You can't cast a C-style string
> to a UTF-16. You'll either need to transcode this string to UTF-16
> yourself, or rely in the XalanDOMString constructor that converts from the
> local code page:
>
> const XalanDOMString encoding("UTF-32");
>
> Then use the following code:
>
> XMLTranscoder* t =
> XMLPlatformUtils::fgTransService->makeNewTranscoderFor(encoding.c_str(),
> code, 16*1024);
>
> Also, please check the "code" variable, in case there's an error.
>
> Finally, I'm not sure why you're transcoding to UTF-32, which is not a
> byte-based encoding. Are you sure about this?
>
> t->transcodeTo(s2, (unsigned int)(args[0]->str()).length(), s1,
>> 200, charsEaten, XMLTranscoder::UnRep_Throw);
>>
> You've told the transcoder there's room for 200 bytes in "s1", but s1 is an
> uninitialized pointer. You can either use a stack-based buffer:
>
> XMLByte s1[200];
>
> or a dynamically-allocated buffer:
>
> XMLByte s1 = new XMLByte[200];
>
> If you use the dynamically-allocated buffer, remember to delete it:
>
> delete [] s1;
>
> You'll also need to either take into account the case where the transcoded
> string doesn't fit into your buffer, or ensure you allocate a large enough
> buffer. For most byte-based encoding the maximum number of bytes per UTF-16
> code unit is 4. For UTF-8, it's 3. For UTF-32, it's usually 1, although
> there are cases where a character will be encoded using 2 UTF-16 code units,
> but only need 1 UTF-32 code unit.
>
> //char *s1 = XMLString::transcode(((args[0]->str()).c_str()));
>> CdxNote<<"s1 = "<<s1<<CdxEndl;
>> catch(XalanDOMException xExcp)
>> {
>> CdxNote<<"Exception caught
>> ="<<xExcp.getExceptionCode()<<CdxEndl;
>> }
>>
>> I am getting args[0]->str() already UTF-16 encoded.So,when i try to encode
>> it to UTF-32 , i am getting a segmentation fault in the line
>> t->transcodeTo(s2, (u....)
>>
> I suspect the transcoder pointer is a null pointer value. Use a debugger
> to see what's going on.
>
> Dave
>