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

There's something wrong with and Encode

Thread Next
Michael G Schwern
March 11, 2008 11:25
There's something wrong with and Encode
Message ID:
lib/Test/Simple/t/utf8.t reveals that there's something wrong with 
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/ 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/ 
line 125.
Cannot find encoding "646" at /export/home/chris/perl588/lib/5.8.8/ 
line 133.


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

The suspicious part of 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 

FWIW _get_locale_encoding() was originally introduced by Jarkko here:

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

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