[xml] encoding question



I modified the example from the tutorial to convert the 
the returned data using UTF8Toisolat1.

void parse(xmlDocPtr doc, xmlNodePtr cur, char* keyword) {
        xmlChar* key;
        char*    cnvkey;

        cur = cur->xmlChildrenNode;
        while (cur != NULL) {
            if ((!xmlStrcmp(cur->name, (const xmlChar *) keyword))) {
                        int inlen;
                    key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
                        inlen=strlen(key);      
                        UTF8Toisolat1(cnvkey, &inlen, key, &inlen);     
                    printf("keyword: %s returns     |%s|\n",keyword, key);
                    printf("keyword: %s returns cnv |%s|\n",keyword, cnvkey);
                    xmlFree(key);
                        xmlFree(cnvkey);/* ?? */
            }
                cur = cur->next;
        }
    return;
}

and now I get the same characters back I typed into the xml file.

But I thought something like UTF8Toisolat1 is done internally for me,
because the of the enconding="ISO-8859-1" in the header of the parsed
document. 

What to do to enable this ?
Have I to free/xmlFree cnvkey ?
--
Regards Klaus



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]