Re: [xml] Encoding problems building document from scratch
- From: Daniel Veillard <veillard redhat com>
- To: "Henke, Markus" <Markus_Henke ordat com>
- Cc: "'xml gnome org'" <xml gnome org>
- Subject: Re: [xml] Encoding problems building document from scratch
- Date: Sun, 13 Jan 2002 15:42:08 -0500
On Fri, Jan 11, 2002 at 01:15:44PM +0100, Henke, Markus wrote:
Hello,
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
http://xmlsoft.org/encoding.html
for libxml2 encoding support choices and description.
Daniel
--
Daniel Veillard | Red Hat Network https://rhn.redhat.com/
veillard redhat com | libxml Gnome XML XSLT toolkit http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]