I have a problem in reading french characters using SAX2XMLReader.
my code works fine with xml file which has all english characters.
but if i have french data in the xml file, SAX2XMLReader->parse( )
fails reporting fatal error.
Is there anything specific should i do using setFeature( ) to
handle non-english characters?
here is the sample code.
bool XMLTree::ParseUsingSAX2()
{
try
{
// Perform per-process parser initialization. The default locale
is "en_US".
XMLPlatformUtils::Initialize();
}
catch (const XMLException& toCatch)
{
// Transcodes a string to native code-page.
char* t_message = XMLString::transcode(toCatch.getMessage());
XMLString::release( &t_message );
return false;
}
SAX2XMLReader* t_parser = XMLReaderFactory::createXMLReader();
if( !t_parser )
{
return false;
}
// Report all validation errors. If this feature is set to true,
// the document must specify a grammar. If this feature is set to
false
// and document specifies a grammar, that grammar might be parsed
but no
// validation of the document contents will be performed.
t_parser->setFeature(XMLUni::fgSAX2CoreValidation, false);
// Perform Namespace processing. If the validation feature is set to
true, then the document
// must contain a grammar that supports the use of namespaces.
t_parser->setFeature(XMLUni::fgSAX2CoreNameSpaces, true); //
optional
mDefaultHandler = new (nothrow) MySAX2Handler(this);
if( !mDefaultHandler )
{
delete t_parser;
return false;
}
// Register a document event handler.
t_parser->setContentHandler( mDefaultHandler );
// Register an error event handler.
t_parser->setErrorHandler( mDefaultHandler );
try
{
t_parser->parse( mFileName.c_str() );
if ( t_parser->getErrorCount() > 0 )
{
delete t_parser;
return false;
}
}
}
I registered call backs for content, warning, error, fatal error
and end document using SAX2XMLReader.
Thanks,
Manoj
Can't identify formerly the language yu use, but you'd better to write
into fr.comp.lang.(java|c|whatever), as this group is almost died.
(je renvoie l'utilisateur vers fr.comp.lang.*)
--
=== The BOFH Excuse Server ===
Your excuse is: You can tune a file system, but you can't tune a fish
(from most tunefs man pages)