#41208 [Asn->Bgs]: saveXML() fails with iso-8859-1 input

From: Date: Fri, 27 Apr 2007 09:27:31 +0000
Subject: #41208 [Asn->Bgs]: saveXML() fails with iso-8859-1 input
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-111988@lists.php.net to get a copy of this message
 ID:               41208
 Updated by:       rrichards@php.net
 Reported By:      scott at realorganized dot com
-Status:           Assigned
+Status:           Bogus
 Bug Type:         DOM XML related
 Operating System: Mac OS X, Linux
 PHP Version:      5.2.1
 Assigned To:      rrichards
 New Comment:

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php

You need to utf-8 encode/decode data:
utf8_encode(chr(200))/utf-8_decode($data)


Previous Comments:
------------------------------------------------------------------------

[2007-04-26 23:45:02] tony2001@php.net

Rob, please verify this.

------------------------------------------------------------------------

[2007-04-26 22:17:58] scott at realorganized dot com

change:
$domfather->saveXML()
to:
$domfather->saveXML($node)

in the example code and execute and no echo at all - no error, 
nothing.  It's like it crashed or something.

------------------------------------------------------------------------

[2007-04-26 21:53:54] scott at realorganized dot com

Description:
------------
When using input encoding of charset=iso-8859-1 domDocument() 
fails to output the ascii code 200 (e grave) using saveXML()

Reproduce code:
---------------
Here's some example code that shows the problem:

<?
  header("Content-Type: text/html; charset=iso-8859-1");
  error_reporting(E_ALL);
  $domfather = new domDocument('1.0', 'iso-8859-1');
  $node = $domfather->createElement("xxx", chr(200));
  $domfather->appendChild($node);
  echo "<pre>";
  echo htmlspecialchars($domfather->saveXML());
  $nodelist =  $domfather->getElementsByTagName("xxx");
  $data = $nodelist->item(0)->nodeValue;
  echo $data;
  echo strlen($data);
?>

Expected result:
----------------
I was expecting the saveXML() to output the e grave symbol (ascii 
200)

iso-8859-1 character mapping is here:

http://old.no/charmap/iso-8859-1.html

and shows that ascii is completely valid.

Please notice that the data is provided correctly when I ask for 
it by node.  the failure is just when using the saveXML() 
function.

Actual result:
--------------
The output from my server is below.  When I retrieve 
the node's data back, it is as expected.  But it's the saveXML() 
code that seems to have a problem. I suspect the problem is with 
the utf-8 -> iso-8859 conversion before output.

Warning:  DOMDocument::saveXML() [function.DOMDocument-saveXML]: 
output conversion failed due to conv error in /Library/Tenon/
WebServer/WebSites/realtyjuggler.com/subscription/test.php on line 
23

Warning:  DOMDocument::saveXML() [function.DOMDocument-saveXML]: 
Bytes: 0xC8 0x3C 0x2F 0x78 in /Library/Tenon/WebServer/WebSites/
realtyjuggler.com/subscription/test.php on line 23

<?xml version="1.0" encoding="iso-8859-1"?>
<xxx>È1


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=41208&edit=1


Thread (5 messages)

« previous php.bugs (#111988) next »