[Moscow.pm] utf8 и Template Toolkit

Vladimir V. Perepelitsa inthrax на gmail.com
Пт Авг 8 05:03:03 PDT 2008


Вот мой хак из доклада

BEGIN {
    use Template::Provider;
    use bytes;
    no warnings 'redefine';
    my $bom = "\x{feff}";
    my $len = length($bom);
    *Template::Provider::_decode_unicode = sub {
        shift;
        my $s = shift;
        # if we have bom, strip it
        $s = substr($s, $len) if substr($s, 0, $len) eq $bom;
        # then decode the string to chars representation
        utf8::decode($s);
        return $s;
    }
}


On Friday 08 August 2008 11:49:02 Dmitry E. Oboukhov wrote:
> то есть я написал примерно такую хрень:
>
> sub _my_decode_unicode
> {
>     my ($self, $string)=@_;
>     $string="\x{ef}\x{bb}\x{bf}$string";
>     $old_decode_unicode->($self, $string);
> }
> $old_decode_unicode=\&Template::Provider::_decode_unicode;
> *Template::Provider::_decode_unicode=\&_my_decode_unicode;
>
> но во первых не очень мне это нравится, во вторых
> как убрать вот такую ругань:
>
> [Fri Aug  8 11:39:46 2008] test_auth.cgi: Subroutine
> Template::Provider::_decode_unicode redefined at ./test_auth.cgi line
> 23.
> ?
> --
> ... mpd is off
>
> . ''`. Dmitry E. Oboukhov
>
> : :’  : unera на debian.org
>
> `. `~’ GPGKey: 1024D / F8E26537 2006-11-21
>   `- 1B23 D4F8 8EC0 D902 0555  E438 AB8C 00CF F8E2 6537



-- 
Vladimir Perepelitsa aka Mons Anderson
<inthrax на gmail.com> / #99779956


Подробная информация о списке рассылки Moscow-pm