develooper Front page | perl.unicode | Postings from March 2007

Encode fallback for iso-2022-jp

Tatsuhiko Miyagawa
March 27, 2007 18:05
Encode fallback for iso-2022-jp
Message ID:

I'm writing a module to see if the given string can be encoded using
the given encoding, to find the minimal encoding to use in outgoing
emails. To do that I call encode() function with FB_CROAK fallback to
see if the encode() function dies.

This approach works realy well, except that I'm having problems with
"iso-2022-jp", because Encode::JP::JIS7 goes:

    my $octet = Encode::encode( 'euc-jp', $utf8, FB_PERLQQ );

and encode all non-jis characters into PERLQQ \x{XXXX} form and
ignores the CHECK flag. Seems to me this is a bug.

-   my $octet = Encode::encode( 'euc-jp', $utf8, FB_PERLQQ );
+   my $octet = Encode::encode( 'euc-jp', $utf8, $chk );

Hope this patch applied. Thanks,

Tatsuhiko Miyagawa Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About