Bug #60142 [Opn->Nab]: XSLTProcessor::transformToXML does not output UTF-8

From: Date: Mon, 02 Dec 2013 14:19:03 +0000
Subject: Bug #60142 [Opn->Nab]: XSLTProcessor::transformToXML does not output UTF-8
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-183059@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=60142&edit=1 ID: 60142 Updated by: mike@php.net Reported by: maximeraoust at gmail dot com -Summary: XSLTProcessor::transformToXML does not output UTF-8 on Windows +Summary: XSLTProcessor::transformToXML does not output UTF-8 -Status: Open +Status: Not a bug Type: Bug Package: XSLT related -Operating System: Windows +Operating System: any PHP Version: 5.3.8 Block user comment: N Private report: N New Comment: You need a proper META content-type for any encoding to be recognized: <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> Previous Comments: ------------------------------------------------------------------------ [2011-10-26 16:32:40] maximeraoust at gmail dot com Fixed title with "Windows" ------------------------------------------------------------------------ [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

« previous php.bugs (#183059) next »