xiaoyafeng has asked for the wisdom of the Perl Monks concerning the following question:

Hi monks,

Several days ago, I posted the question about WRAPPER. Thanks sincere help by monks, I use this way to fulfill my target.

But....... this new trick bring me new problem. Below are my partial codes:

wrapper.tt [% IF no_wrapper; content; ELSE; wrapper = wrapper || 'full.tt'; content WRAPPER $wrapper; END; -%]
full.tt <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w +3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <!-- Design by Andy --> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link href="static/css/default.css" rel="stylesheet" type="text/css" / +> <meta name="Keywords" content="" /> <meta name="Description" content="" /> <link rel="stylesheet" type="text/css" media="screen" href="static/css +/ui-lightness/jquery-ui-1.8.1.custom.css" /> <script type="text/javascript" src="static/js/jquery-1.4.2.min.js" > </script> .............. .............. include some Asian characters ............. ............. <div id="footer"> <p>Copyright (c) 2010 Andy All rights reserved. Design by Andy </p +> </div> <div style="font-size: 0.8em; text-align: center;"> <br /> <br /> </div> </body> </html>
Myapp.pm package Myapp; use Moose; use namespace::autoclean; use Catalyst::Runtime 5.80; # Set flags and add plugins for the application # # -Debug: activates the debug mode for very useful log message +s # ConfigLoader: will load the configuration from a Config::General f +ile in the # application's home directory # Static::Simple: will serve static files from the application's root # directory use Catalyst qw/ -Debug ConfigLoader Static::Simple StackTrace Unicode /; </p>
some controller code: sub purchase_manage : Local { my ( $self, $c ) = @_; $c->stash(no_wrapper => 0); $c->stash(merchants => [$c->model('WindyDB::Merchant')->all]); # T +here are some Asian characters stored in DB. $c->stash(persons => [$c->model('WindyDB::person')->all]); # dit +to $c->stash(no_wrapper => 0); $c->stash(template => 'purchase_manage.tt');
package UW::Model::WindyDB; use lib '/opt/oracle/product/11.2.0/dbhome_1/perl/lib/site_perl/5.10.0 +/i686-linux-thread-multi/'; use strict; use base 'Catalyst::Model::DBIC::Schema'; __PACKAGE__->config( schema_class => 'UW::Schema', connect_info => { dsn => 'dbi:Oracle:oraUW', user => 'UW', password => 'windy123', {oracharset => 'AL32UTF8'} } );
The odd thing is:

Any thoughts? I'm looking forward to any replies! TIA





I am trying to improve my English skills, if you see a mistake please feel free to reply or /msg me a correction

Replies are listed 'Best First'.
Re: Catalyst WRAPPER and Unicode (Episode 2)
by Your Mother (Archbishop) on Jun 13, 2010 at 03:45 UTC

    Follow this: Using Unicode in Catalyst Applications. If you make sure the layers are right on their own and you include the plugin as directed, it'll work right. If it's not working right, something is wrong in one of the layers (or something in your environment; I recently discovered for example that mysql will/can double encode if the encoding is set in the defaults file and the DBD layer). The directive INSERT had, IIRC, encoding issues in the past but if the template file's BOM is right it should be fine and PROCESS and INCLUDE never suffered from the issue (again IIRC).

    (update: Make sure you configuration layer is up to date. YAML::XS for YAML, e.g., instead of something older.)

      Thanks!

      I added ENCODING => 'utf-8' into view package and all is correct.





      I am trying to improve my English skills, if you see a mistake please feel free to reply or /msg me a correction