Subject: | does not recognize default locale '646' on Solaris |
Encode (actually Encode::Alias) does not work with the default locale on Solaris 8/9/10
because Solaris reports the CODESET to be '646' and Encode::Alias does not recognize that.
This is a critical issue because it causes :locale to be unrecognized which leads to a segfault
in the Perl 5.8.8 distribution (which I'm still trying to pin point the cause of)
and thereby breaks tests like the utf8 test recently added to Test::Simple
making it difficult to update core modules via cpan.
The solution is to add into Encode::Alias in the ASCII section something like
define_alias( '646' => 'ascii' );
The issue can be shown with the following bit of Perl code
======
use I18N::Langinfo qw(langinfo CODESET);
print langinfo(CODESET()), "\n";
======
which prints 646
and then
======
use encoding ':locale';
======
which produces
encoding: Unknown encoding '646' at ./t1 line 5
BEGIN failed--compilation aborted at ./t1 line 5.
And the following bit of C code verifies the 646 is coming from Solaris
======
#include <locale.h>
#include <langinfo.h>
#include <nl_types.h>
main ()
{ char * v;
setlocale(LC_ALL, "");
v = nl_langinfo(CODESET);
printf("%s\n", v);
}
=====
which prints 646
We know that Solaris' CODESET 646 should be understood to be ISO 646 because of
http://docs.sun.com/app/docs/doc/806-5584/6jej8rb1g?a=view
and
because it is also referred to as the "C" locale in Solaris environ(5) in the discussion of LANG
Regards,
Todd Olson