Re: [xml] Encoding problems building document from scratch

On Fri, Jan 11, 2002 at 01:15:44PM +0100, Henke, Markus wrote:

and sorry that i post this again. But i've posted it before as a RE: to
my original posting and that's maybe mistakable since it's no answer,
rather a follow-up question that includes some debugging information
and a possible solution that seems to work, although i don't know
if it's the right way to handle these things...

  Not the right way the problem is at the very beginning:

/* encode entities for new node content */
char* contentBuff = "Some content < & > aou äöü AOU ÄÖÜ ß üöä ";
tmpBuff = xmlEncodeEntitiesReentrant(docPtr, BAD_CAST contentBuff);

/* Add node */
xmlNewChild(docPtr, NULL, "aNode", tmpBuff);

  The problem is there. It's not permitted to do this. The tree is
expected to be maintained in UTF8. xmlEncodeEntitiesReentrant() 
will escape "special" chars like '<>&' but will NOT try to handle
charset conversion.
  You need to convert first the string to UTF8. There is a function
exported from encoding.h to do IsoLatin1 to UTF8 encoding. Check
  for libxml2 encoding support choices and description.


Daniel Veillard      | Red Hat Network
veillard redhat com  | libxml Gnome XML XSLT toolkit | Rpmfind RPM search engine

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