Template::Tookit で html_entity フィルタが文字化けする。

Template/Filters.pm を読むと、Apache::Util::escape_html を試してから、HTML::Entities::encode_entities を試すようだ。


Apache/Util.pm を読むと:

item escape_html

This routine replaces unsafe characters in $string with their entity
representation.

 my $esc = Apache::Util::escape_html($html);

This function will correctly escape US-ASCII output. If you are using
a different character set such as UTF8, or need more control on
the escaping process, use HTML::Entities.

ガクッ。「US-ASCII は正しくエスケープするけど、UTF8 とかはダメです。HTML::Entities を使い給え」とな。


対処法予想:

  • みんな Apache::Util を入れない/抜いてる(mod_perl 使うなら必要なんじゃないの?)
  • みんな Template/Filters.pm を書き換えてる(HTML::Entities::encode_entities を先に試行)
  • みんな カスタムフィルタを作って対処してる(HTML::Entities::encode_entities に押し付けるだけ)

うそーん。


上のエントリと合わせて無知を曝け出してるよなぁ、きっと。