I ran into the same problem. I found some code in the mail list archive that does the transcoding of the UTF-16 into a vector of chars and then populates an STL string by iterating through the vector from begin() to end(). It turns out that code had a bug in it, the iteration through the vector should stop at end() - 1. The result of going to end() was to place an extra NULL character in the data portion of the string so that a string that was assigned, say, "file" would actually have 5 characters in the data() portion of the string so compare()s to "file" would fail due to differing lengths. I fixed that and encapsulated it all into a class that I call XalanDomCString. I've attached the class header and implementation, and example of using it would be something like:
catch (XSLException& ex)
{
XalanDomCString myCString(ex.getMessage);
Printf("caught XSLException, message is %s\n", myCString.c_str());
}
BTW, I did it as a nested class inside the main Profile class because
there was no need for it outside of the Profile. YMMV.
HTH,
-will
-----Original Message-----
From: Coker, Jonathan M [mailto:[EMAIL PROTECTED]
Sent: Wednesday, April 04, 2007 4:19 PM
To: [email protected]
Subject: Tangled strings
Hello,
Thanks to David and Will for the help with moving the parser into a
class. I have that working so I am moving on to more involved
development. I am currently stumbling over the extraction of a C++
string from XalanDOMString after a call to XalanNode::getNodeValue(). I
am getting the the XalanDOMString but my attempts to transcode (like I
did in Xerces) have failed. I have not gone through all of the API
documents but I am hoping that I have just missed something simple.
Thanks again
XalanDomCString.h
Description: XalanDomCString.h
XalanDomCString.cpp
Description: XalanDomCString.cpp
