Re: [xml] question about encoding

On Wed, Mar 07, 2001 at 07:59:16PM +0100, Thomas Dold wrote:
I try to create document with the encoding ISO-8859-1.
I did like:
   doc = xmlNewDoc((xmlChar*)"1.0"); 
   doc->encoding = xmlStrDup((xmlChar*)"ISO-8859-1"); 

I tried to add a property to a node with:
   xmlSetProp(node, (xmlChar*)"town", (xmlChar*)"München");

Everything works quite good, till I try to save the document
with xmlSaveFile or xmlSaveFileEnc with the encoding ISO-8859-1.
Then I get the error:
   xmlSaveFileEnc: document not in UTF-8


Then I read the document about the internalization-support of libxml but 'm
not sure if I understood it right.

  seems so ...

Is it necessary to convert every string to UTF-8, befor I can use ist in a
function like xmlSetProp?

  yes, all internal representation is in UTF8,

In another message I found, that there are functions like isolat1ToUTF8 and
UTF8Toisolat1. They are public defined but not in the headerfile. Should I
use this functions for the conversions?

  yes, you can use them, I should make sure they get expeorted properly

Is it right, that I have to convert the strings also, when I read them from
the document e.g. with xmlGetProp?


Is there an easier way to work with document not encoded in UTF-8 than
calling the conversion-functions before and after the libxml-functions?

No, the internal representation is UTF8 and that cannot be changed easilly.


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

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