DateTime locale names and wide characters

[email protected] (Shane McCarron)
Newsgroups perl.datetime
Message-ID <CACCbJAY0CXGidhHUMFNLec-mtF0Z6T5h9r1aXwZxY=X=JQUS8A@mail.gmail.com>
I have run into something sort of odd....  I wanted to give users of a web
application a list of date locales to pick from for personalizing their
displays.  So I created a hash of mappings from each
DateTime::Locale->ids() value to the name for each Locale object.  The code
looks something like this:

    my @data ;

    foreach my $id ( DateTime::Locale->ids() ) {
        my $ref = DateTime::Locale->load( $id ) ;
        if ($ref) {
            push(@data, { val => $id, desc => $ref->name()  } ) ;
        }
    }

The @data list is then sorted (by desc) and used to populate a <select>
element in a web form.  Here's the weird thing.  When I am using this under
Apache on a Linux platform in a CGI application, I get a warning that I am
printing 'wide characters' when I use data from the 'desc' as the content
of an 'option' element.  What I *think* is that the data coming out of
DateTime::Locale is not properly encoded as Perl's utf8 internal encoding.
 If I take the outout of the name() and native_name() methods and encode
them using "Encode", then it no longer complains.  Is this expected
behavior?

-- 
Shane McCarron
[email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.