Edit report at https://bugs.php.net/bug.php?id=60142&edit=1

 ID:                 60142
 User updated by:    maximeraoust at gmail dot com
 Reported by:        maximeraoust at gmail dot com
-Summary:            XSLTProcessor::transformToXML does not output UTF-8
+Summary:            XSLTProcessor::transformToXML does not output UTF-8
                     on Windows
 Status:             Open
 Type:               Bug
 Package:            XSLT related
 Operating System:   Windows
 PHP Version:        5.3.8
 Block user comment: N
 Private report:     N

 New Comment:

Fixed title with "Windows"


Previous Comments:
------------------------------------------------------------------------
[2011-10-26 16:16:12] maximeraoust at gmail dot com

Sorry, I obviously meant:

echo $proc->transformToXml($doc);

------------------------------------------------------------------------
[2011-10-26 16:13:01] maximeraoust at gmail dot com

In the test script, you can also put:

echo $proc->transformToXml(); to get the output, same result

------------------------------------------------------------------------
[2011-10-26 16:11:10] maximeraoust at gmail dot com

Description:
------------
XSLTProcessor::transformToXML never seem to output UTF-8 data. 

Bug was already reported (https://bugs.php.net/bug.php?id=36415 & 
https://bugs.php.net/bug.php?id=36407&edit=2) but not enough information were 
provided and reports were closed. So here's attached a complete test.

I'm running PHP 5.3.8 VC9 + Apache 2.2.21 VC9 on Windows 7 Professional SP1.

I also tested on 5.3.2 under Ubuntu 10.04.3 and it works fine.



Test script:
---------------
<?php
$xslt = '<?xml version="1.0" encoding="utf-8"?><xsl:stylesheet 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; version="1.0"><xsl:output 
method="text" /></xsl:stylesheet>';
$inputText = 'UTF-8 text with accents: éèàç';

$doc = new DOMDocument('1.0', 'UTF-8');
$doc->loadHTML($inputText);

$xsl = new DOMDocument('1.0', 'UTF-8');
$xsl->loadXML($xslt);

$proc = new XSLTProcessor();
$proc->importStylesheet($xsl);

echo $proc->transformToDoc($doc)->saveXML();
?>

Expected result:
----------------
It should output (in CLI):

<?xml version="1.0"?>
UTF-8 text with accents: &#xE9;&#xE8;&#xE0;&#xE7;

Or if displayed in browser:

UTF-8 text with accents: éèàç

Actual result:
--------------
It outputs:

<?xml version="1.0"?>
UTF-8 text with accents: &#xC3;&#xA9;&#xC3;&#xA8;&#xC3;&#xA0;&#xC3;&#xA7;

Or if displayed in browser:

UTF-8 text with accents: éèà ç


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



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

Reply via email to