検索の文字化け解決の為、再度、Zend Framework1.6のCHMを作ってみる。
検索が文字化けしていたので、文字化けにしないように変更
今度は、HTMLもUTF-8⇒SJIS変換するようにしました。
まずは、ドキュメントをダウンロード
http://framework.zend.com/download/current/
Documentationの下にあるDownloadをクリック
日本語のzipをクリック
CHMへコンパイルする前に一手間加える。
以下のスクリプトを作成
make_htmlhelp_ja.hhp.php
<?php if (!is_file('htmlhelp.hhp')) { echo 'Not Found htmlhelp.hhp'."\r\n"; echo 'Please press Ctrl + C'."\r\n"; file_get_contents('php://stdin'); exit; } if (!is_file('toc.hhc')) { echo 'Not Found toc.hhc'."\r\n"; echo 'Please press Ctrl + C'."\r\n"; file_get_contents('php://stdin'); exit; } $buff = to_sjis('htmlhelp.hhp', 'UTF-8'); $buff = str_replace('toc.hhc', 'toc_ja.hhc', $buff); file_put_contents('htmlhelp_ja.hhp', $buff); $buff = to_sjis('toc.hhc', 'UTF-8'); file_put_contents('toc_ja.hhc', $buff); $items = glob("*.html"); foreach($items as $num=>$item) { file_put_contents($item, to_sjis_doc($item, 'UTF-8')); } function to_sjis($file, $encoding) { $keys['iso-8859-1'] = 'SJIS'; $buff = strtr(file_get_contents($file), $keys); $utf8_buff = html_entity_decode($buff, ENT_NOQUOTES, $encoding); $sjis_buff = mb_convert_encoding($utf8_buff, 'SJIS', $encoding); // return $sjis_buff; } function to_sjis_doc($file, $encoding) { $keys['; charset=UTF-8'] = '; charset=SJIS'; $keys['>?<'] = '> <'; $buff = file_get_contents($file); $sjis_buff = mb_convert_encoding($buff, 'SJIS', $encoding); // return strtr($sjis_buff, $keys); }
このスクリプトをhtmlhelp.hhpと同じディレクトリに保存して
実行すると・・・
というファイルを生成します。