Hi Dave, We have a similar problem here while using transcode in our external function. It throws the TranscodingError for strings in East Asian Languages. Our function actually encodes the XalanDOMString, for which we need to get std::string from XalanDOMString. Similar to what you said I have read it at many places that its not good to transcode to the local code page, but I could not find any other method of Xalan that gives me a C string.
Could you please provide any suggestions regarding this. Regards, Jasmine David Bertoni wrote: > > souri datta wrote: >> Hi, >> In the external function whenever I am getting an argument which has >> some Unicode chars in it,when i try to convert it to std::string..it is >> causing transcode(..) method carshes. > All of the characters in a XalanDOMString are "Unicode characters." Do > you mean non-ASCII characters? > >> For example >> >> suppose in the external function args[0]->str() contains some Unicode >> chars. >> so when I do (args[0]->str()).transcode(opVector); // opVector is of >> type CharVectorType; >> it is crashing. > It's probably not crashing. It may be throwing an exception because > you're trying to transcode to a local code page that cannot represent > all of the characters in the string. > > You might want to try surrounding the transcoding block with a try/catch > handler: > > try > { > args[0]->str().transcode(opVector); > } > catch(const XalanDOMString::TranscodingError&) > { > std::cerr << "Transcoding failed!\n"; > } > > In general, it's a bad idea to transcode to the local code page, since > it may not be able to encode all of the characters in the XalanDOMString. > > Dave > > -- View this message in context: http://old.nabble.com/Problem%3AUnicode-string-causing-transcode%28..%29-crashes-in-External-Function-tp19878741p29479242.html Sent from the Xalan - C - Users mailing list archive at Nabble.com.