Hi,
Translating to the local code page is a very bad application design. You
should transcode to UTF-8 instead, since you will be guaranteed that all
characters can be represented. Probably what's happening is some
characters are not representable in the local code page, and
XMLString::transcode() is failing.
For more information about transcoding to UTF-8, you might want to read the
documentation, or search the mailing list archive. This question has
definitely come up before.
Dave
"cedric
LEFEBVRE" To: "xerces-c-dev" <[EMAIL
PROTECTED]>
<[EMAIL PROTECTED] cc: (bcc: David N
Bertoni/Cambridge/IBM)
com> Subject: Re: Seg fault when receiving
cyrillic characters
01/02/2004 09:11
AM
Please respond
to xerces-c-dev
void MyEventSaxHandler::characters( const XMLCh* const chars
, const unsigned int length)
{
if (!strcmp(_curElt, "argument"))
{
_event->addArgument(_tag.c_str(),
StrX(chars).localForm());
}
}
The translation is done like this:
XMLString::transcode(toTranscode)
I'll need to investigate to find out the buffer size of evt.
Christelle
---------- Initial Header -----------
>From : Alberto Massari <[EMAIL PROTECTED]>
To : [EMAIL PROTECTED]
Cc :
Date : Fri, 02 Jan 2004 15:00:31 +0100
Subject : Re: Seg fault when receiving cyrillic characters
At 14.52 02/01/2004 +0100, Steel Bash wrote:
>Here is the code of the addArgument function
>
>map<string, string> _arguments;
>
>void MyEvent::addArgument(const char * substag, const char * value)
>{
> string sub = substag;
> string val = value;
> _arguments[sub] = val;
>}
This function works with char*, but the MyEventSaxHandler::characters()
handler receives Unicode characters; how do you translate them? Can you
post the code for that function too?
>The map is working fine on its own with cyrillic characters.
>
>I think the error is when specifying the size of the buffer as you
>mentionned. How do you get the size in bytes and not in char ?
You should know it; how do you get the buffer that the evt pointer points
to?
Alberto
>Christelle
>
>---------- Initial Header -----------
>
>From : Alberto Massari <[EMAIL PROTECTED]>
>To : [EMAIL PROTECTED]
>Cc :
>Date : Fri, 02 Jan 2004 14:18:04 +0100
>Subject : Re: Seg fault when receiving cyrillic characters
>
>As the stack shows, the crash is happening inside your own code
>(MyEvent::addArgument() at straits.h:125). Unless you post it, we cannot
>help you.
>Also, I see that you are creating a MemBufInputSource object that holds
the
>XML document; but the document seems to be Unicode, but you are using
>strlen to compute its size. You should enter the size (in bytes) of the
>buffer, and not relying on strlen (that works only on non-Unicode buffers)
>
>Alberto
>
>At 14.07 02/01/2004 +0100, Steel Bash wrote:
> >Hello,
> >
> >We've developped an application that works great with latin characters.
We
> >need now to make it working with languages such as russian or japanese.
> >For now when the parser receives a russian characters we have a
> >segmentation fault. What do we need to do to make the parser handling
> >unicode characters ?
> >
> >Here is a snippet of the code we are using:
> >and the XMl document that is sent as a test
> ><?xml version="1.0" encoding="UTF-16"?>
> ><!DOCTYPE event SYSTEM "event.dtd">
> ><event id="1">
> > <argument name="sArg">???? Russian characters here ???</argument>
> ></event>
> >
> >MyEventAccumulator::_doit()
> >{
> >char * evt;
> >MyEventSaxHandler handler;
> >SAXParser parser;
> >SAXParser::ValSchemes valScheme = SAXParser::Val_Always;
> >bool doNamespaces = false;
> >bool doSchema = false;
> >
> >parser.setValidationScheme(valScheme);
> >parser.setDoNamespaces(doNamespaces);
> >parser.setDoSchema(doSchema);
> >parser.setDocumentHandler(&handler);
> >parser.setErrorHandler(&handler);
> >parser.setEntityResolver(&handler);
> >....
> >MemBufInputSource * memBufIS = new MemBufInputSource
> >(
> >(const XMLByte *) (evt),
> >strlen(evt),
> >"some event",
> >false
> >);
> >try
> >{
> >parser.parse(*memBufIS);
> >}
> >catch (const XMLException & e)
> >{
> >// Parse error
> >// cerr << "Error parsing event" << endl;
> >}
> >}
> >...
> >}
> >
> >This is where the segmentation fault occurs (before catching any
> exceptions).
> >
> >The DDD backtrace
> >
> >#8 0x0805327a in MyEventAccumulator::_doit() at
MyEventAccumulator.cpp:117
> >#7 0x4018d373 in SAXParser::parse() from libxerces-c1_7_0.so
> >#6 0x401d339c in XMLScanner::scanDocument() from libxerces-c1_7_0.so
> >#5 0x401d5a6d in XMLScanner::scanContent() from libxerces-c1_7_0.so
> >#4 0x401d07d5 in XMLScanner::scanCharData() from libxerces-c1_7_0.so
> >#3 0x401ce4ea in XMLScanner::sendCharData() from libxerces-c1_7_0.so
> >#2 0x4018dcf8 in SAXParser::doCharacters() from libxerces-c1_7_0.so
> >#1 0x0805503f in MyEventSaxHandler::characters() at bastring.h:343
> >#0 0x0804fc84 in MyEvent::addArgument() at straits.h:125
> >
> >Any idea ?
> >
> >Christelle
> >********** PROTEGEZ VOS E-MAILS !********** Avec Tiscali SuperMail, vos
> >e-mails en toute sécurité ! Anti Spam personnalisable Anti Virus
actualisé
> >en permanence et de nombreux bonus... Pour en savoir plus, rendez-vous
sur
> >http://www.tiscali.fr/supermail/
> >
> >
> >---------------------------------------------------------------------
> >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]
>
>********** PROTEGEZ VOS E-MAILS !********** Avec Tiscali SuperMail, vos
>e-mails en toute sécurité ! Anti Spam personnalisable Anti Virus actualisé
>en permanence et de nombreux bonus... Pour en savoir plus, rendez-vous sur
>http://www.tiscali.fr/supermail/
>
>
>---------------------------------------------------------------------
>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]
********** PROTEGEZ VOS E-MAILS !**********
Avec Tiscali SuperMail, vos e-mails en toute sécurité !
Anti Spam personnalisable
Anti Virus actualisé en permanence
et de nombreux bonus...
Pour en savoir plus, rendez-vous sur http://www.tiscali.fr/supermail/
---------------------------------------------------------------------
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]