blob: dc0335fed1fc8cc47036596040fe9831273ba6fa [file] [log] [blame]
Daniel Veillard1177ca42003-04-26 22:29:54 +00001<?xml version="1.0" encoding="ISO-8859-1"?>
2<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /><link rel="SHORTCUT ICON" href="/favicon.ico" /><style type="text/css">
Daniel Veillard373a4752002-02-21 14:46:29 +00004TD {font-family: Verdana,Arial,Helvetica}
5BODY {font-family: Verdana,Arial,Helvetica; margin-top: 2em; margin-left: 0em; margin-right: 0em}
6H1 {font-family: Verdana,Arial,Helvetica}
7H2 {font-family: Verdana,Arial,Helvetica}
8H3 {font-family: Verdana,Arial,Helvetica}
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00009A:link, A:visited, A:active { text-decoration: underline }
Daniel Veillard1177ca42003-04-26 22:29:54 +000010</style><title>Encodings support</title></head><body bgcolor="#8b7765" text="#000000" link="#000000" vlink="#000000"><table border="0" width="100%" cellpadding="5" cellspacing="0" align="center"><tr><td width="180"><a href="http://www.gnome.org/"><img src="gnome2.png" alt="Gnome2 Logo" /></a><a href="http://www.w3.org/Status"><img src="w3c.png" alt="W3C Logo" /></a><a href="http://www.redhat.com/"><img src="redhat.gif" alt="Red Hat Logo" /></a><div align="left"><a href="http://xmlsoft.org/"><img src="Libxml2-Logo-180x168.gif" alt="Made with Libxml2 Logo" /></a></div></td><td><table border="0" width="90%" cellpadding="2" cellspacing="0" align="center" bgcolor="#000000"><tr><td><table width="100%" border="0" cellspacing="1" cellpadding="3" bgcolor="#fffacd"><tr><td align="center"><h1>The XML C library for Gnome</h1><h2>Encodings support</h2></td></tr></table></td></tr></table></td></tr></table><table border="0" cellpadding="4" cellspacing="0" width="100%" align="center"><tr><td bgcolor="#8b7765"><table border="0" cellspacing="0" cellpadding="2" width="100%"><tr><td valign="top" width="200" bgcolor="#8b7765"><table border="0" cellspacing="0" cellpadding="1" width="100%" bgcolor="#000000"><tr><td><table width="100%" border="0" cellspacing="1" cellpadding="3"><tr><td colspan="1" bgcolor="#eecfa1" align="center"><center><b>Main Menu</b></center></td></tr><tr><td bgcolor="#fffacd"><form action="search.php" enctype="application/x-www-form-urlencoded" method="get"><input name="query" type="text" size="20" value="" /><input name="submit" type="submit" value="Search ..." /></form><ul><li><a href="index.html">Home</a></li><li><a href="intro.html">Introduction</a></li><li><a href="FAQ.html">FAQ</a></li><li><a href="docs.html">Developer Documentation</a></li><li><a href="bugs.html">Reporting bugs and getting help</a></li><li><a href="help.html">How to help</a></li><li><a href="downloads.html">Downloads</a></li><li><a href="news.html">News</a></li><li><a href="XMLinfo.html">XML</a></li><li><a href="XSLT.html">XSLT</a></li><li><a href="xmldtd.html">Validation &amp; DTDs</a></li><li><a href="encoding.html">Encodings support</a></li><li><a href="catalog.html">Catalog support</a></li><li><a href="namespaces.html">Namespaces</a></li><li><a href="contribs.html">Contributions</a></li><li><a href="guidelines.html">XML Guidelines</a></li></ul></td></tr></table><table width="100%" border="0" cellspacing="1" cellpadding="3"><tr><td colspan="1" bgcolor="#eecfa1" align="center"><center><b>Related links</b></center></td></tr><tr><td bgcolor="#fffacd"><ul><li><a href="http://mail.gnome.org/archives/xml/">Mail archive</a></li><li><a href="http://xmlsoft.org/XSLT/">XSLT libxslt</a></li><li><a href="http://phd.cs.unibo.it/gdome2/">DOM gdome2</a></li><li><a href="http://www.aleksey.com/xmlsec/">XML-DSig xmlsec</a></li><li><a href="ftp://xmlsoft.org/">FTP</a></li><li><a href="http://www.zlatkovic.com/projects/libxml/">Windows binaries</a></li><li><a href="http://garypennington.net/libxml2/">Solaris binaries</a></li><li><a href="http://www.zveno.com/open_source/libxml2xslt.html">MacOsX binaries</a></li><li><a href="http://sourceforge.net/projects/libxml2-pas/">Pascal bindings</a></li><li><a href="http://bugzilla.gnome.org/buglist.cgi?product=libxml&amp;product=libxml2">Bug Tracker</a></li></ul></td></tr></table></td></tr></table></td><td valign="top" bgcolor="#8b7765"><table border="0" cellspacing="0" cellpadding="1" width="100%"><tr><td><table border="0" cellspacing="0" cellpadding="1" width="100%" bgcolor="#000000"><tr><td><table border="0" cellpadding="3" cellspacing="1" width="100%"><tr><td bgcolor="#fffacd"><p>Table of Content:</p><ol><li><a href="encoding.html#What">What does internationalization support
Daniel Veillardb8cfbd12001-10-25 10:53:28 +000011 mean ?</a></li>
Daniel Veillard0b28e882002-07-24 23:47:05 +000012 <li><a href="encoding.html#internal">The internal encoding, how and
Daniel Veillardb8cfbd12001-10-25 10:53:28 +000013 why</a></li>
Daniel Veillard0b28e882002-07-24 23:47:05 +000014 <li><a href="encoding.html#implemente">How is it implemented ?</a></li>
15 <li><a href="encoding.html#Default">Default supported encodings</a></li>
16 <li><a href="encoding.html#extend">How to extend the existing
Daniel Veillardb8cfbd12001-10-25 10:53:28 +000017 support</a></li>
Daniel Veillard1177ca42003-04-26 22:29:54 +000018</ol><h3><a name="What" id="What">What does internationalization support mean ?</a></h3><p>If you are not really familiar with Internationalization (usual shorcut is
Daniel Veillard238836e2003-04-07 22:57:29 +000019I18N) , Unicode, characters and glyphs, I suggest you read a <a href="http://www.tbray.org/ongoing/When/200x/2003/04/06/Unicode">presentation</a>
Daniel Veillard1177ca42003-04-26 22:29:54 +000020by Tim Bray on Unicode and why you should care about it.</p><p>XML was designed from the start to allow the support of any character set
Daniel Veillardbe40c8b2000-07-14 12:10:59 +000021by using Unicode. Any conformant XML parser has to support the UTF-8 and
22UTF-16 default encodings which can both express the full unicode ranges. UTF8
Daniel Veillard63d83142002-05-20 06:51:05 +000023is a variable length encoding whose greatest points are to reuse the same
24encoding for ASCII and to save space for Western encodings, but it is a bit
Daniel Veillardbe40c8b2000-07-14 12:10:59 +000025more complex to handle in practice. UTF-16 use 2 bytes per characters (and
Daniel Veillardb8cfbd12001-10-25 10:53:28 +000026sometimes combines two pairs), it makes implementation easier, but looks a
27bit overkill for Western languages encoding. Moreover the XML specification
28allows document to be encoded in other encodings at the condition that they
Daniel Veillard63d83142002-05-20 06:51:05 +000029are clearly labeled as such. For example the following is a wellformed XML
Daniel Veillard0d6b1702000-08-22 23:52:16 +000030document encoded in ISO-8859 1 and using accentuated letter that we French
Daniel Veillard1177ca42003-04-26 22:29:54 +000031likes for both markup and content:</p><pre>&lt;?xml version=&quot;1.0&quot; encoding=&quot;ISO-8859-1&quot;?&gt;
32&lt;très&gt;là&lt;/très&gt;</pre><p>Having internationalization support in libxml means the following:</p><ul><li>the document is properly parsed</li>
Daniel Veillard0b28e882002-07-24 23:47:05 +000033 <li>informations about it's encoding are saved</li>
34 <li>it can be modified</li>
35 <li>it can be saved in its original encoding</li>
36 <li>it can also be saved in another encoding supported by libxml (for
Daniel Veillardbe40c8b2000-07-14 12:10:59 +000037 example straight UTF8 or even an ASCII form)</li>
Daniel Veillard1177ca42003-04-26 22:29:54 +000038</ul><p>Another very important point is that the whole libxml API, with the
Daniel Veillardbe40c8b2000-07-14 12:10:59 +000039exception of a few routines to read with a specific encoding or save to a
40specific encoding, is completely agnostic about the original encoding of the
Daniel Veillard1177ca42003-04-26 22:29:54 +000041document.</p><p>It should be noted too that the HTML parser embedded in libxml now obey
Daniel Veillardbe40c8b2000-07-14 12:10:59 +000042the same rules too, the following document will be (as of 2.2.2) handled in
Daniel Veillard1177ca42003-04-26 22:29:54 +000043an internationalized fashion by libxml too:</p><pre>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0 Transitional//EN&quot;
Daniel Veillardb8cfbd12001-10-25 10:53:28 +000044 &quot;http://www.w3.org/TR/REC-html40/loose.dtd&quot;&gt;
45&lt;html lang=&quot;fr&quot;&gt;
Daniel Veillardbe40c8b2000-07-14 12:10:59 +000046&lt;head&gt;
Daniel Veillardb8cfbd12001-10-25 10:53:28 +000047 &lt;META HTTP-EQUIV=&quot;Content-Type&quot; CONTENT=&quot;text/html; charset=ISO-8859-1&quot;&gt;
Daniel Veillardbe40c8b2000-07-14 12:10:59 +000048&lt;/head&gt;
49&lt;body&gt;
50&lt;p&gt;W3C crée des standards pour le Web.&lt;/body&gt;
Daniel Veillard1177ca42003-04-26 22:29:54 +000051&lt;/html&gt;</pre><h3><a name="internal" id="internal">The internal encoding, how and why</a></h3><p>One of the core decision was to force all documents to be converted to a
Daniel Veillardbe40c8b2000-07-14 12:10:59 +000052default internal encoding, and that encoding to be UTF-8, here are the
Daniel Veillard1177ca42003-04-26 22:29:54 +000053rationale for those choices:</p><ul><li>keeping the native encoding in the internal form would force the libxml
Daniel Veillardbe40c8b2000-07-14 12:10:59 +000054 users (or the code associated) to be fully aware of the encoding of the
Daniel Veillardb8cfbd12001-10-25 10:53:28 +000055 original document, for examples when adding a text node to a document,
56 the content would have to be provided in the document encoding, i.e. the
Daniel Veillardbe40c8b2000-07-14 12:10:59 +000057 client code would have to check it before hand, make sure it's conformant
58 to the encoding, etc ... Very hard in practice, though in some specific
59 cases this may make sense.</li>
Daniel Veillard0b28e882002-07-24 23:47:05 +000060 <li>the second decision was which encoding. From the XML spec only UTF8 and
Daniel Veillardbe40c8b2000-07-14 12:10:59 +000061 UTF16 really makes sense as being the two only encodings for which there
Daniel Veillard63d83142002-05-20 06:51:05 +000062 is mandatory support. UCS-4 (32 bits fixed size encoding) could be
Daniel Veillardbe40c8b2000-07-14 12:10:59 +000063 considered an intelligent choice too since it's a direct Unicode mapping
64 support. I selected UTF-8 on the basis of efficiency and compatibility
65 with surrounding software:
Daniel Veillard1177ca42003-04-26 22:29:54 +000066 <ul><li>UTF-8 while a bit more complex to convert from/to (i.e. slightly
Daniel Veillardbe40c8b2000-07-14 12:10:59 +000067 more costly to import and export CPU wise) is also far more compact
68 than UTF-16 (and UCS-4) for a majority of the documents I see it used
69 for right now (RPM RDF catalogs, advogato data, various configuration
70 file formats, etc.) and the key point for today's computer
71 architecture is efficient uses of caches. If one nearly double the
72 memory requirement to store the same amount of data, this will trash
73 caches (main memory/external caches/internal caches) and my take is
74 that this harms the system far more than the CPU requirements needed
75 for the conversion to UTF-8</li>
Daniel Veillard0b28e882002-07-24 23:47:05 +000076 <li>Most of libxml version 1 users were using it with straight ASCII
Daniel Veillardbe40c8b2000-07-14 12:10:59 +000077 most of the time, doing the conversion with an internal encoding
78 requiring all their code to be rewritten was a serious show-stopper
79 for using UTF-16 or UCS-4.</li>
Daniel Veillard0b28e882002-07-24 23:47:05 +000080 <li>UTF-8 is being used as the de-facto internal encoding standard for
Daniel Veillardbe40c8b2000-07-14 12:10:59 +000081 related code like the <a href="http://www.pango.org/">pango</a>
82 upcoming Gnome text widget, and a lot of Unix code (yep another place
Daniel Veillardb8cfbd12001-10-25 10:53:28 +000083 where Unix programmer base takes a different approach from Microsoft
84 - they are using UTF-16)</li>
Daniel Veillard1177ca42003-04-26 22:29:54 +000085 </ul></li>
86</ul><p>What does this mean in practice for the libxml user:</p><ul><li>xmlChar, the libxml data type is a byte, those bytes must be assembled
Daniel Veillardb8cfbd12001-10-25 10:53:28 +000087 as UTF-8 valid strings. The proper way to terminate an xmlChar * string
88 is simply to append 0 byte, as usual.</li>
Daniel Veillard0b28e882002-07-24 23:47:05 +000089 <li>One just need to make sure that when using chars outside the ASCII set,
Daniel Veillardbe40c8b2000-07-14 12:10:59 +000090 the values has been properly converted to UTF-8</li>
Daniel Veillard1177ca42003-04-26 22:29:54 +000091</ul><h3><a name="implemente" id="implemente">How is it implemented ?</a></h3><p>Let's describe how all this works within libxml, basically the I18N
Daniel Veillardbe40c8b2000-07-14 12:10:59 +000092(internationalization) support get triggered only during I/O operation, i.e.
93when reading a document or saving one. Let's look first at the reading
Daniel Veillard1177ca42003-04-26 22:29:54 +000094sequence:</p><ol><li>when a document is processed, we usually don't know the encoding, a
Daniel Veillardbe40c8b2000-07-14 12:10:59 +000095 simple heuristic allows to detect UTF-18 and UCS-4 from whose where the
96 ASCII range (0-0x7F) maps with ASCII</li>
Daniel Veillard0b28e882002-07-24 23:47:05 +000097 <li>the xml declaration if available is parsed, including the encoding
Daniel Veillardb8cfbd12001-10-25 10:53:28 +000098 declaration. At that point, if the autodetected encoding is different
99 from the one declared a call to xmlSwitchEncoding() is issued.</li>
Daniel Veillard0b28e882002-07-24 23:47:05 +0000100 <li>If there is no encoding declaration, then the input has to be in either
Daniel Veillardbe40c8b2000-07-14 12:10:59 +0000101 UTF-8 or UTF-16, if it is not then at some point when processing the
102 input, the converter/checker of UTF-8 form will raise an encoding error.
103 You may end-up with a garbled document, or no document at all ! Example:
104 <pre>~/XML -&gt; ./xmllint err.xml
105err.xml:1: error: Input is not proper UTF-8, indicate encoding !
106&lt;très&gt;là&lt;/très&gt;
107 ^
108err.xml:1: error: Bytes: 0xE8 0x73 0x3E 0x6C
109&lt;très&gt;là&lt;/très&gt;
110 ^</pre>
Daniel Veillard0b28e882002-07-24 23:47:05 +0000111 </li>
112 <li>xmlSwitchEncoding() does an encoding name lookup, canonicalize it, and
Daniel Veillardbe40c8b2000-07-14 12:10:59 +0000113 then search the default registered encoding converters for that encoding.
114 If it's not within the default set and iconv() support has been compiled
115 it, it will ask iconv for such an encoder. If this fails then the parser
116 will report an error and stops processing:
117 <pre>~/XML -&gt; ./xmllint err2.xml
118err2.xml:1: error: Unsupported encoding UnsupportedEnc
Daniel Veillardb8cfbd12001-10-25 10:53:28 +0000119&lt;?xml version=&quot;1.0&quot; encoding=&quot;UnsupportedEnc&quot;?&gt;
Daniel Veillardbe40c8b2000-07-14 12:10:59 +0000120 ^</pre>
Daniel Veillard0b28e882002-07-24 23:47:05 +0000121 </li>
122 <li>From that point the encoder processes progressively the input (it is
Daniel Veillardb8cfbd12001-10-25 10:53:28 +0000123 plugged as a front-end to the I/O module) for that entity. It captures
124 and convert on-the-fly the document to be parsed to UTF-8. The parser
125 itself just does UTF-8 checking of this input and process it
126 transparently. The only difference is that the encoding information has
127 been added to the parsing context (more precisely to the input
128 corresponding to this entity).</li>
Daniel Veillard0b28e882002-07-24 23:47:05 +0000129 <li>The result (when using DOM) is an internal form completely in UTF-8
Daniel Veillardb8cfbd12001-10-25 10:53:28 +0000130 with just an encoding information on the document node.</li>
Daniel Veillard1177ca42003-04-26 22:29:54 +0000131</ol><p>Ok then what happens when saving the document (assuming you
Daniel Veillard63d83142002-05-20 06:51:05 +0000132collected/built an xmlDoc DOM like structure) ? It depends on the function
Daniel Veillardbe40c8b2000-07-14 12:10:59 +0000133called, xmlSaveFile() will just try to save in the original encoding, while
134xmlSaveFileTo() and xmlSaveFileEnc() can optionally save to a given
Daniel Veillard1177ca42003-04-26 22:29:54 +0000135encoding:</p><ol><li>if no encoding is given, libxml will look for an encoding value
Daniel Veillardbe40c8b2000-07-14 12:10:59 +0000136 associated to the document and if it exists will try to save to that
137 encoding,
138 <p>otherwise everything is written in the internal form, i.e. UTF-8</p>
Daniel Veillard0b28e882002-07-24 23:47:05 +0000139 </li>
140 <li>so if an encoding was specified, either at the API level or on the
Daniel Veillard63d83142002-05-20 06:51:05 +0000141 document, libxml will again canonicalize the encoding name, lookup for a
Daniel Veillardbe40c8b2000-07-14 12:10:59 +0000142 converter in the registered set or through iconv. If not found the
143 function will return an error code</li>
Daniel Veillard0b28e882002-07-24 23:47:05 +0000144 <li>the converter is placed before the I/O buffer layer, as another kind of
Daniel Veillardbe40c8b2000-07-14 12:10:59 +0000145 buffer, then libxml will simply push the UTF-8 serialization to through
146 that buffer, which will then progressively be converted and pushed onto
147 the I/O layer.</li>
Daniel Veillard0b28e882002-07-24 23:47:05 +0000148 <li>It is possible that the converter code fails on some input, for example
Daniel Veillard63d83142002-05-20 06:51:05 +0000149 trying to push an UTF-8 encoded Chinese character through the UTF-8 to
Daniel Veillard0d6b1702000-08-22 23:52:16 +0000150 ISO-8859-1 converter won't work. Since the encoders are progressive they
Daniel Veillardbe40c8b2000-07-14 12:10:59 +0000151 will just report the error and the number of bytes converted, at that
152 point libxml will decode the offending character, remove it from the
153 buffer and replace it with the associated charRef encoding &amp;#123; and
Daniel Veillard63d83142002-05-20 06:51:05 +0000154 resume the conversion. This guarantees that any document will be saved
Daniel Veillardb8cfbd12001-10-25 10:53:28 +0000155 without losses (except for markup names where this is not legal, this is
Daniel Veillard63d83142002-05-20 06:51:05 +0000156 a problem in the current version, in practice avoid using non-ascii
Daniel Veillardb8cfbd12001-10-25 10:53:28 +0000157 characters for tags or attributes names @@). A special &quot;ascii&quot; encoding
Daniel Veillard0d6b1702000-08-22 23:52:16 +0000158 name is used to save documents to a pure ascii form can be used when
159 portability is really crucial</li>
Daniel Veillard1177ca42003-04-26 22:29:54 +0000160</ol><p>Here is a few examples based on the same test document:</p><pre>~/XML -&gt; ./xmllint isolat1
Daniel Veillardb8cfbd12001-10-25 10:53:28 +0000161&lt;?xml version=&quot;1.0&quot; encoding=&quot;ISO-8859-1&quot;?&gt;
Daniel Veillardbe40c8b2000-07-14 12:10:59 +0000162&lt;très&gt;là&lt;/très&gt;
163~/XML -&gt; ./xmllint --encode UTF-8 isolat1
Daniel Veillardb8cfbd12001-10-25 10:53:28 +0000164&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
Daniel Veillardbe40c8b2000-07-14 12:10:59 +0000165&lt;très&gt;là  &lt;/très&gt;
Daniel Veillard1177ca42003-04-26 22:29:54 +0000166~/XML -&gt; </pre><p>The same processing is applied (and reuse most of the code) for HTML I18N
Daniel Veillardbe40c8b2000-07-14 12:10:59 +0000167processing. Looking up and modifying the content encoding is a bit more
Daniel Veillardb8cfbd12001-10-25 10:53:28 +0000168difficult since it is located in a &lt;meta&gt; tag under the &lt;head&gt;,
169so a couple of functions htmlGetMetaEncoding() and htmlSetMetaEncoding() have
Daniel Veillardbe40c8b2000-07-14 12:10:59 +0000170been provided. The parser also attempts to switch encoding on the fly when
Daniel Veillardb8cfbd12001-10-25 10:53:28 +0000171detecting such a tag on input. Except for that the processing is the same
Daniel Veillard1177ca42003-04-26 22:29:54 +0000172(and again reuses the same code).</p><h3><a name="Default" id="Default">Default supported encodings</a></h3><p>libxml has a set of default converters for the following encodings
173(located in encoding.c):</p><ol><li>UTF-8 is supported by default (null handlers)</li>
Daniel Veillard0b28e882002-07-24 23:47:05 +0000174 <li>UTF-16, both little and big endian</li>
175 <li>ISO-Latin-1 (ISO-8859-1) covering most western languages</li>
176 <li>ASCII, useful mostly for saving</li>
177 <li>HTML, a specific handler for the conversion of UTF-8 to ASCII with HTML
Daniel Veillardbe40c8b2000-07-14 12:10:59 +0000178 predefined entities like &amp;copy; for the Copyright sign.</li>
Daniel Veillard1177ca42003-04-26 22:29:54 +0000179</ol><p>More over when compiled on an Unix platform with iconv support the full
Daniel Veillardc0801af2002-05-28 16:28:42 +0000180set of encodings supported by iconv can be instantly be used by libxml. On a
Daniel Veillardb8cfbd12001-10-25 10:53:28 +0000181linux machine with glibc-2.1 the list of supported encodings and aliases fill
1823 full pages, and include UCS-4, the full set of ISO-Latin encodings, and the
Daniel Veillard1177ca42003-04-26 22:29:54 +0000183various Japanese ones.</p><h4>Encoding aliases</h4><p>From 2.2.3, libxml has support to register encoding names aliases. The
Daniel Veillardb8cfbd12001-10-25 10:53:28 +0000184goal is to be able to parse document whose encoding is supported but where
185the name differs (for example from the default set of names accepted by
186iconv). The following functions allow to register and handle new aliases for
187existing encodings. Once registered libxml will automatically lookup the
Daniel Veillard1177ca42003-04-26 22:29:54 +0000188aliases when handling a document:</p><ul><li>int xmlAddEncodingAlias(const char *name, const char *alias);</li>
Daniel Veillard0b28e882002-07-24 23:47:05 +0000189 <li>int xmlDelEncodingAlias(const char *alias);</li>
190 <li>const char * xmlGetEncodingAlias(const char *alias);</li>
191 <li>void xmlCleanupEncodingAliases(void);</li>
Daniel Veillard1177ca42003-04-26 22:29:54 +0000192</ul><h3><a name="extend" id="extend">How to extend the existing support</a></h3><p>Well adding support for new encoding, or overriding one of the encoders
Daniel Veillardbe40c8b2000-07-14 12:10:59 +0000193(assuming it is buggy) should not be hard, just write an input and output
194conversion routines to/from UTF-8, and register them using
195xmlNewCharEncodingHandler(name, xxxToUTF8, UTF8Toxxx), and they will be
196called automatically if the parser(s) encounter such an encoding name
197(register it uppercase, this will help). The description of the encoders,
198their arguments and expected return values are described in the encoding.h
Daniel Veillard1177ca42003-04-26 22:29:54 +0000199header.</p><p>A quick note on the topic of subverting the parser to use a different
Daniel Veillardb8cfbd12001-10-25 10:53:28 +0000200internal encoding than UTF-8, in some case people will absolutely want to
201keep the internal encoding different, I think it's still possible (but the
202encoding must be compliant with ASCII on the same subrange) though I didn't
203tried it. The key is to override the default conversion routines (by
204registering null encoders/decoders for your charsets), and bypass the UTF-8
205checking of the parser by setting the parser context charset
206(ctxt-&gt;charset) to something different than XML_CHAR_ENCODING_UTF8, but
Daniel Veillard63d83142002-05-20 06:51:05 +0000207there is no guarantee that this will work. You may also have some troubles
Daniel Veillard1177ca42003-04-26 22:29:54 +0000208saving back.</p><p>Basically proper I18N support is important, this requires at least
Daniel Veillardbe40c8b2000-07-14 12:10:59 +0000209libxml-2.0.0, but a lot of features and corrections are really available only
Daniel Veillard1177ca42003-04-26 22:29:54 +0000210starting 2.2.</p><p><a href="bugs.html">Daniel Veillard</a></p></td></tr></table></td></tr></table></td></tr></table></td></tr></table></td></tr></table></body></html>