Le 7 août 07 à 11:31, Tobias Kremer a écrit :

Hey folks,

I'm utilizing DateTime::Locale to get at the month names for different
languages. With Catalyst I'm having problems with the encoding of special
characters used in the month names:

Controller:
$c->stash->{ 'month_names' } =
  DateTime::Locale->load( 'de' )->month_names;

Template:
[% month_names.join(",") %]

gives me:
Januar,Februar,M[questionmark]rz,April etc.

Explicitly encoding the month names as utf8 fixes the error:

$c->stash->{ 'month_names_encoded' } = [
  map { encode( 'utf8' ) }
    @{ DateTime::Locale->load( 'de' )->month_names }
];

(The content-type is set to utf-8.)

Any ideas what's going on or what I'm doing wrong? The explicit encoding shouldn't be neccessary IMHO and it makes it hard to use third- party modules (e.g. form generation/validation frameworks) that build on DateTime::Locale to
generate a list of month_names for the given locale.

I don't think this is a DateTime::Locale issue, as it provides it strings in utf8 with the utf8 bit set. Rather it seems that the TT template object wasn't initialized with
the UNICODE option set.

--
Éric Cholet


Reply via email to