encodings...

[email protected] ("Alexander Belyaev") Fri, 19 Dec 2003 14:39:59 +0300
Newsgroups php.xml.dev
Message-ID <[email protected]>
Hi,

Daniel Veillard wrote "One just need to make sure that when using chars
outside the ASCII set, the values has been properly converted to UTF-8"
(from http://www.xmlsoft.org/encoding.html)

In practice, if I wrote constructs like

$dom = new domDocument;
$xmlstr="<?xml version='1.0'  encoding='windows-1251'?>
<chapter language='en'>
 <para language='ru'>??????</para>
 <para language='en'>hi</para>
</chapter>";
$rootnode = $dom->documentElement;
$myelement = new domElement("test", $a); /* $a - in win1251 charset*/
$newchild = $rootnode->appendChild($myelement);

I have a problems. Yes, I need iconv $a to UTF8.
libxml2 wants UTF-8 as input for building document,
but UTF-8 is not widely used charset, 90% of common web software are not
utf-8 ready,
90% or more users(except java-world :) wants national 8bit charsets ...
But libxml2 orthodox in this. We cannot use plain dom extension api,
we need userspace classes to hide internal iconv work.

It is possible to add domDocument property "defaultInputEncoding"
and if it set to something else than utf-8 convert all input to utf-8
internally..?
...
or function like set_input_encoding($enc);

I can provide a patch...


--
With best regards & wishes,
Alexander
mailto:[email protected]
http://www.graphit.ru/