php/phd — pull request #3 by mumumu (2013-06-27 16:02:01+00:00)
Title: PhD generates garbled chm on PHP 5.4.0 or later.

a) Description

PhD generates garbled chm on PHP 5.4.0 or later, because of htmlspecialchars spec change (newly supports some encodings, CP932 and the default value for the encoding parameter was changed to UTF-8).
http://php.net/manual/en/function.htmlspecialchars.php

This issue cannot be reproduced on PHP 5.3.x.

b) How reproducible

Always on PHP 5.4.x, PHP 5.5.0

c) How to reproduce

1. install PHP and the latest PhD (1.1.6 or git version)
2. svn co http://svn.php.net/repository/phpdoc/modules/doc-ja
2. php doc-base/configure.php --with-lang=ja --enable-xml-details --disable-libxml-check
3. phd -f chm -P PHP -L ja -d doc-base/.manual.xml

d) Expected result

In the following files, the valeu of "name () is not empty. not garbled.

output/php-chm/php_manual_ja.hhc
output/php-chm/php_manual_ja.hhk

e) Actual Result

In the following files, the valeu of "name () is empty.
this is because htmlspecialchars function's return value is empty by specifying default encoding.

output/php-chm/php_manual_ja.hhc
output/php-chm/php_manual_ja.hhk

f) Suggesting fix

Pull request's source.
We should specify htmlspecialchars third parameter (encoding) with preferred_charset.

g) Extended Notes

This fix emits E_NOTICE in some locale on PHP 5.3.x, because 'CP932' and some encodings are not supported on htmlspecialchars on PHP 5.3.x. But this is not affected because PHP 5.3.x fallback to ISO-8859-1.