External functions using universal charstrings [message #1831036] |
Mon, 10 August 2020 08:42  |
Eclipse User |
|
|
|
Hi Titan experts,
I am using external functions to process XML documents via the excelent libxml2.
I have now the problems that the MCC TF160 ATSs at ETSI will use universal charstrings instead of charstrings.
Previously I used following cast operators, which worked fine:
/*
* Returns given node in XML document referred via an xpath expression using libxml2
*/
CHARSTRING fx__XML__GetElement(const CHARSTRING& p_XMLDoc,
const CHARSTRING& p_Xpath) {
const char *v_XMLDoc = (const char *) static_cast<const unsigned char*>(p_XMLDoc);
xmlChar *xPath = (xmlChar *) static_cast<const char*>(p_Xpath);
....
}
This does not work if I have now UNIVERSAL CHARSTRINGS instead of CHARSTRINGS.
Besides, CHARSTRINGS are NULL terminated, whereas UNIVERSAL CHARSTRINGS seem to be not NULL terminated, so I can not just cast the pointers.
Any idea how I can adapt the code above using UNIVERSAL CHARSTRINGs?
The complete (faulty !) code is in the attached file.
Thanks for any hint.
Olaf Bergengruen
|
|
|
|
|
|
Re: External functions using universal charstrings [message #1831069 is a reply to message #1831068] |
Tue, 11 August 2020 02:45  |
Eclipse User |
|
|
|
Thanks , Gabor again.
Since v_XMLDOC_oct is not NULL terminated, I had to do additional work, which resulted in following code, which may not be the best, but it works.
OCTETSRTING v_XMLDOC_oct = unichar2oct(p_XMLDoc);
size_t v_XMLDoc_len = v_XMLDOC_oct;.lengthof();
char *v_XMLDoc;
// Prepare v_XMLDoc
v_XMLDoc = (char *) calloc( v_XMLDoc_len + 1, 1); // Allocate memory and init to 0
memcpy((char *) v_XMLDoc, (const char *) (const unsigned char*) tmp_oct1, v_XMLDoc_len);
// Do the work
// Don't forget
free(v_XMLDoc);
So, now it is done, at least for the moment.
Regards,
Olaf
|
|
|
Powered by
FUDForum. Page generated in 0.03978 seconds