in reply to Re^5: UTF-8 webpage output from MySQL
in thread UTF-8 webpage output from MySQL
And we know that your template isn't set up correctly.
This works for me:
#!/usr/bin/perl use strict; use warnings; use Template::Alloy; use Devel::Peek; binmode STDOUT, ':utf8'; my $t = Template::Alloy->new( filename => "utf8test", ENCODING => 'UTF-8', ); Dump $t->output; print $t->output; __END__ file utf8test: testaråäöÅÄÖ ============== output: SV = PV(0x825c260) at 0x82d629c REFCNT = 1 FLAGS = (TEMP,POK,pPOK,UTF8) PV = 0x82d5ea0 "testar\303\245\303\244\303\266\303\205\303\204\303\2 +26\n"\0 [UTF8 "testar\x{e5}\x{e4}\x{f6}\x{c5}\x{c4}\x{d6}\n"] CUR = 19 LEN = 20 testaråäöÅÄÖ
And this what I get when I store the file utf8test is latin1, and run the script again:
SV = PV(0x825c260) at 0x82d629c REFCNT = 1 FLAGS = (TEMP,POK,pPOK,UTF8) PV = 0x8332cc0 "testar\357\277\275\357\277\275\357\277\275\357\277\2 +75\357\277\275\357\277\275\n"\0 [UTF8 "testar\x{fffd}\x{fffd}\x{fffd} +\x{fffd}\x{fffd}\x{fffd}\n"] CUR = 25 LEN = 28 testar������
Strangely similar to your output, isn't it?
So it seems taht your template file is not in utf-8, and therefore all attempts to read it as utf-8 result in the \X{fffd} "replacement character".
So either recode your templates to utf-8 (future-proof) or read them with the right ENCODING option (presumably latin1).
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^7: UTF-8 webpage output from MySQL
by boboson (Monk) on Jan 24, 2008 at 08:35 UTC | |
|
Re^7: UTF-8 webpage output from MySQL
by boboson (Monk) on Jan 25, 2008 at 07:42 UTC |