develooper Front page | perl.perl5.porters | Postings from March 2008

There's something wrong with open.pm and Encode

Thread Next
From:
Michael G Schwern
Date:
March 11, 2008 11:25
Subject:
There's something wrong with open.pm and Encode
Message ID:
47D6CE9D.4080008@pobox.com
lib/Test/Simple/t/utf8.t reveals that there's something wrong with open.pm. 
Things like this:

$ perl5.10.0 -wle 'use Encode::Alias;  use open ":std", ":locale"'
Can't locate object method "find_alias" via package "Encode" at 
/usr/local/perl/5.10.0/lib/5.10.0/darwin-thread-multi-2level/Encode.pm line 101.
BEGIN failed--compilation aborted at -e line 1.

C<use open ":std", ":locale"> crashes on a number of platforms, usually with 
something like this:
Cannot find encoding "646" at /export/home/chris/perl588/lib/5.8.8/open.pm 
line 125.
Cannot find encoding "646" at /export/home/chris/perl588/lib/5.8.8/open.pm 
line 133.

(See http://www.nntp.perl.org/group/perl.cpan.testers/2008/03/msg1137710.html)

Finally, talking with Merijn I discovered that while open.pm can't find the 
"roman8" encoding there is an hp-roman8 encoding which Encoding::Alias aliases 
to "roman8".

The suspicious part of open.pm is this:

             if ($layer eq 'locale') {
                 require Encode;
                 require encoding;
                 $locale_encoding = encoding::_get_locale_encoding()
                     unless defined $locale_encoding;
                 (warnings::warnif("layer", "Cannot figure out an encoding to 
use"), last)                    unless defined $locale_encoding;

Anything digging into private functions of another module raises alarm bells. 
  My guess is this is bypassing the smarts that would normally be applied by 
Encode.

FWIW _get_locale_encoding() was originally introduced by Jarkko here:
http://public.activestate.com/cgi-bin/perlbrowse/p/11236


-- 
Being faith-based doesn't trump reality.
	-- Bruce Sterling


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About