|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #17241 encoding error?
Submitted: 2002-05-15 05:57 UTC Modified: 2002-09-17 01:00 UTC
Avg. Score:4.2 ± 0.8
Reproduced:4 of 4 (100.0%)
Same Version:1 (25.0%)
Same OS:1 (25.0%)
From: pipo at club dot idecnet dot com Assigned:
Status: No Feedback Package: DOM XML related
PHP Version: 4.2.0 OS: slackware linux 2.4.16
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: pipo at club dot idecnet dot com
New email:
PHP Version: OS:


 [2002-05-15 05:57 UTC] pipo at club dot idecnet dot com
I have found problems using documents with different encodings. 

When I add nodes from one document to another ($docAItem->add_child($docB->root()), if the flag encoding property of the target document has not been set  when initially creating the document (using functions xmldoc, xmldocfile, etc., not setting the property manually with '$doc->encoding = "utf8"') then the encoding translation is not done. 
A possible workaround for this situation is to force the flag using dumpmem with the optional encoding flag set. ie:
$docA = domxml_new_xmldoc(?1.0?);
$docARoot = $docA->add_root(?root?);
$docA = xmldoc($docA->dumpmem(0, ?UTF8?));

It looks like the encoding property of the DomDocument object can?t be set manually.
Also, when creating a new DomDocument from scratch (with domxml_new_xmldoc) the encoding property should be set to UTF8 as a default, or allow a second optional parameter in the xmldoc function to set the proper encoding. 

byeer, pipo_


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2002-08-14 10:40 UTC]
Properties of Dom Objects are read-only, only created at generation time and therefore not really reliable...

The internal encoding of domxml is always utf8, could you please give a short selfcontained example for the "add nodes from one document to another"-problem?

But you gave the right solution, for having another encoding at output.

 [2002-09-17 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 [2002-10-28 09:55 UTC] dan at mojavelinux dot com
Here is the main problem regarding this bug.  If you want to enter data into your xml document that is encoding in iso-8859-0 because the encoding on your document is set to iso-8859-0, it screws up because the internal encoding is always set to utf-8.  This is fine, but the input encoding is also always set to utf-8...if you want to enter iso8859-1 data into the tree, there should be an option to set the input encoding so that it converts it appropriately to utf-8.  Otherwise, the user is forced to do
iconv('ISO-8859-1', 'UTF-8', 'string') each time he/she wants to enter data into the document.  I believe you should be able to set the expected input encoding and have it automatically convert it.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Jul 13 19:01:30 2024 UTC