use Encode; sub cgiapp_postrun { my($this, $response_ref)=@_; my $encoding = ... #figure out which encoding to use if($encoding ne "UTF-8") { my $response_utf8 = decode('UTF-8', $$response_ref); $$response_ref = encode('ISO-8859-1', $response_utf8); }