Apache::Filter::HanConvert - Filter between Chinese variant and encodings


This document describes version 0.02 of Apache::Filter::HanConvert, released December 12, 2002.


In httpd.conf:

    PerlModule Apache::Filter::HanConvert
    PerlOutputFilterHandler Apache::Filter::HanConvert
    PerlSetVar HanConvertFromVariant "traditional"


This module utilizes the Encode::HanConvert module with Apache2's output filtering mechanism, to provide a flexible and customizable solution for serving multiple encoding/variants from the same source documents.

From the settings in "SYNOPSIS", the server would negotiate with the client's browser about their Accept-Language preference (zh-cn and zh means Simplified, other zh-* means Traditional), as well as the preferred Accept-Charset setting (defaults to utf8 if nothing was explicitly specified).

The Content-Type header will be rewritten to reflect the final encoding used.

If you want to use other encodings, try adding these lines:

    PerlSetVar HanConvertFromEncoding "UTF-8"
    PerlSetVar HanConvertToEncodingTraditional "big5"
    PerlSetVar HanConvertToEncodingSimplified "gbk"

Finally, if you'd like to dictate it to always convert to a specific variant/encoding, use this:

    PerlSetVar HanConvertToVariant "simplified"
    PerlSetVar HanConvertToEncoding "gbk"


The HanConvertFromEncoding config probably could take multiple encodings and apply Encode::Guess to find out the correct source encoding.

Currently this module does not work with mod_dir, so the server's DirectoryIndex setting won't be honored. Patches welcome!


Apache2, Encode::HanConvert, Encode


Autrijus Tang <>


Copyright 2002 by Autrijus Tang <>.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.