Hi all,

I have in my mason handler defined PREAMBLE "use utf8;", exactly:
sub handler {
        my ($r) = @_;
        my $ah = HTML::Mason::ApacheHandler->new(
                ...
                args_method             => "mod_perl",
                preamble                => "use utf8;",
                ...
);

anyway, the generated obj code is not correct.

Here is a demonstration:

Main component (called utf8test.mhtm)
        === cut here start ===
<% $utf1 %><br>
<% $utf2 %><br>
<%init>
        my $datacomp = $m->fetch_comp('without_useutf.mc');
        my $utf1 = $datacomp->attr_if_exists('utf8');

        $datacomp = $m->fetch_comp('with_useutf.mc');
        my $utf2 = $datacomp->attr_if_exists('utf8');
</%init>
        === cut here end ===
SImply - fetch another two components, and if named attr "utf8" exists, get 
them and print them...

The component "without_useutf.mc"
        === cut here start ===
<%attr>
        utf8 => '=č=cCaron =€=EUR =Ω=Greek capital OMEGA'
</%attr>
        === cut here end ===

and the component "with_useutf.mc"
        === cut here start ===
<%attr>
        utf8 => '=č=cCaron =€=EUR =Ω=Greek capital OMEGA'
</%attr>
<%once>
        use utf8;       #this is in the ONCE-section
</%once>
        === cut here end ===

the result in the browser:
the first line - (utf1 - what comes from a component without "use utf8;') is 
incorrect,
the second line (utf2 - what comes from a component WITH use utf8) is OK.

Therefore I think, this is a bug, or I missed something... :-)

Workaround exists - simply enough enter to all components with utf8 ATTR 
sections, the ONCE block, but would be much nicer, if mason compile the 
preamble block not only to code section, but to the obj top section too.

Here are the "compiled" versions (.obj) files of two components:
the file: without_useutf.obj

        === cut here start ===
package HTML::Mason::Commands;
use strict;
use vars qw($m $r $d);
HTML::Mason::Component::FileBased->new(
'attr' => {
utf8 => '=č=cCaron =€=EUR =Ω=Greek capital OMEGA'
},
'code' => sub {
use utf8;$m->debug_hook( $m->current_comp->path ) if ( 
HTML::Mason::Compiler::IN_PERL_DB() );

;return;
},
'load_time' => 1285776495,

)
;
        === cut here end ===


and the file with_useutf.obj

        === cut here start ===
package HTML::Mason::Commands;
use strict;
use vars qw($m $r $d);
#line 4 "/Users/clt/Web/Mad/Documents/special/with_useutf.mc"

        use utf8;       #this is in the ONCE-section
HTML::Mason::Component::FileBased->new(
'attr' => {
utf8 => '=č=cCaron =€=EUR =Ω=Greek capital OMEGA'
},
'code' => sub {
use utf8;$m->debug_hook( $m->current_comp->path ) if ( 
HTML::Mason::Compiler::IN_PERL_DB() );

;return;
},
'load_time' => 1285779767,

)
;
        === cut here end ===

as you can see, the only difference is in the "use utf8;" line AT THE TOP of 
component.
the attr-block has a correct strings in both version, but not in output...
The output is this:
=č=cCaron =€=EUR =Ω=Greek capital OMEGA
=č=cCaron =€=EUR =Ω=Greek capital OMEGA

the 1st line is bad, second is OK...


jm.
ps: sry for my terrible english...

------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
Mason-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mason-users

Reply via email to