Perl

NAVIGATION
CATEGORIES
REFERRENCE
LINKS
  • Double encoding of the rseult from UTF8 template

    1 answers - 1031 bytes - related search similar search Add To My Delicious Add To My Stumble Upon Add To My Google Mark Add To My Facebook Add To My Digg Add To My Reddit

    Hi,
    I'm trying to populate TT2 utf8 template with variables which also
    contain utf8 characters. After processing with TT2, the static text in
    the template looks double encoded to Unicode (utf8::encode) but the
    dynamic text (the one that comes from vars) is K.
    I use perl 5.8.6, TT 2.14, my perl script is:
    #!/usr/bin/perl
    use strict;
    use utf8;
    use Template;
    my $template = Template->new({ INCLUDE_PATH ='.' });
    $template->process('test.tt', { test ="test" }, '/tmp/x', binmode =':utf8' )
    || die $template->error();
    If I don't specify binmode the problem occurs only when I use wide
    characters for the value of the var test (if run with latin value
    'test', the output of /tmp/x is fine).
    Thanks in advance!
    P.S. Any share of experience with utf8 templates and utf8 vars would
    be appreciated
    templates mailing list
    templates (AT) template-toolkit (DOT) org
  • No.1 | | 1332 bytes | |

    Five minutes after I sent this email (and preceded from an hour long
    googling and testing) I found the problem -- I put "use encoding
    'utf8';" and everything worked fine.

    Sorry for the inconvenience

    2005/11/26, Svilen Ivanov <svilen.ivanov (AT) gmail (DOT) com>:
    Hi,

    I'm trying to populate TT2 utf8 template with variables which also
    contain utf8 characters. After processing with TT2, the static text in
    the template looks double encoded to Unicode (utf8::encode) but the
    dynamic text (the one that comes from vars) is K.

    I use perl 5.8.6, TT 2.14, my perl script is:

    #!/usr/bin/perl
    use strict;
    use utf8;

    use Template;
    my $template = Template->new({ INCLUDE_PATH ='.' });
    $template->process('test.tt', { test ="test" }, '/tmp/x', binmode =':utf8' )
    || die $template->error();

    If I don't specify binmode the problem occurs only when I use wide
    characters for the value of the var test (if run with latin value
    'test', the output of /tmp/x is fine).

    Thanks in advance!

    P.S. Any share of experience with utf8 templates and utf8 vars would
    be appreciated

    templates mailing list
    templates (AT) template-toolkit (DOT) org

Re: Double encoding of the rseult from UTF8 template


max 4000 letters.
Your nickname that display:
In order to stop the spam: 4 + 3 =
QUESTION ON "Perl"

EMSDN.COM