The solution to my last problem (attached) brought up a new problem regarding 
UTF-8.

= Problem =

The following code:
 $c->redirect(
   $c::uri_for(
     '/login',
     {error_msg => "Check my å"}
   );
 );

Gives me this URL in my browser:
 http://localhost:3000/login?error_msg=Check+my+%C3%83%C2%A5

Which prints this on my webpage:
 Check my å

The content type of the webpage is UTF-8.


= Possible solution =

Remove line 967 from Catalyst.pm (v5.7011):
          (map {
              $_ = "$_";
# THIS ONE              utf8::encode( $_ ); 
              # using the URI::Escape pattern here so utf8 chars survive
              s/([^A-Za-z0-9\-_.!~*'() ])/$URI::Escape::escapes{$1}/go;
              s/ /+/g;
              "${key}=$_"; } ( ref $val eq 'ARRAY' ? @$val : $val ));


= Questions =

- It works as a solution to me, does it break anything for others?
- Why is that line there at all?
- Shouldn't URI::Escape be enough?



-- 
Knut-Olav Hoven
Systemutvikler               mob: +47 986 71 700
Linpro AS                    http://www.linpro.no/
--- Begin Message ---
There are some problems when translating with Catalyst::Plugin::I18N using 
special unicode characters like "æøå".

It got printed (both in console/debugging) and in web browser) as unprintable 
characters (displayed as "?"). Manually changing encoding in Firefox to 
ISO-8859-1 made it look right, but the rest of the page is using UTF-8, so 
this was a no-go solution for me.

The solution I found to this was to change line 65 of Catalyst/Plugin/I18N.pm 
(version 0.06), changed the Decode attribute given 
to "Locale::Maketext::Simple" from 1 to 0.

Any particular reason why Decode was 1?

If Decode=>1 is needed for somebody, this should definitely be a configurable 
option.


Patch attached

-- 
Knut-Olav Hoven
Systemutvikler               mob: +47 986 71 700
Linpro AS                    http://www.linpro.no/
Index: lib/Catalyst/Plugin/I18N.pm
===================================================================
--- lib/Catalyst/Plugin/I18N.pm	(revisjon 390)
+++ lib/Catalyst/Plugin/I18N.pm	(revisjon 397)
@@ -46,6 +46,22 @@
    our %Lexicon = ( 'Hello Catalyst' => 'Hallo Katalysator' );
    1;
 
+=head1 CONFIGURATION
+
+To override the C<Decode> parameter (default to 0), set up configuration in
+your MyApp.pm file like this:
+
+ __PACKAGE__->config(
+    'i18n'  => {
+        'decode'    => 1,
+    },
+ );
+
+or if using YAML configuration file:
+
+ i18n:
+    decode: 1
+
 =head2 EXTENDED METHODS
 
 =head3 setup
@@ -60,9 +76,10 @@
     my $file = "$calldir.pm";
     my $path = $INC{$file};
     $path =~ s#\.pm$#/I18N#;
+    my $decode  = $self->config->{'i18n'}{'decode'} ? 1 : 0;
     eval <<"";
       package $self;
-      import Locale::Maketext::Simple Path => '$path', Export => '_loc', Decode => 1;
+      import Locale::Maketext::Simple Path => '$path', Export => '_loc', Decode => $decode;
 
 
     if ($@) {

Attachment: signature.asc
Description: This is a digitally signed message part.

_______________________________________________
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[EMAIL PROTECTED]/
Dev site: http://dev.catalyst.perl.org/

--- End Message ---

Attachment: signature.asc
Description: This is a digitally signed message part.

_______________________________________________
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[EMAIL PROTECTED]/
Dev site: http://dev.catalyst.perl.org/

Reply via email to