Skip Menu |
 

This queue is for tickets about the Encode CPAN distribution.

Report information
The Basics
Id: 107905
Status: resolved
Priority: 0/
Queue: Encode

People
Owner: Nobody in particular
Requestors: dolmen [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: (no value)
Fixed in: 2.73



Subject: netbsd: encoding::_get_locale_encoding returns invalid encoding name (Encode < 2.73)
On netbsd with Encode 2.60:
    perl -w '-MEncode 2.05' -mencoding -e 'print encoding::_get_locale_encoding, $/'
    646

The "646" value comes directly from I18N::Langinfo

    perl -MI18N::Langinfo=langinfo,CODESET -e 'print langinfo(CODESET), $/'
    646

I think this is an issue that has been fixed in 2.73 (with my rewrite of encoding::_get_locale_encoding), however this is not enforced by tests.
https://github.com/dankogai/p5-encode/commit/4ed9ed08d2943ffc222863bc353a4a6e484c97db

Unfortunately I don't have direct access to a netbsd system to fully understand the issue (I found the issue through CPAN Testers).


So the next step would be to add a test that checks encoding::_get_locale_encoding returns either undef or the name of an encoding known to Encode.
That test would also dump the result of langinfo, the current locale (POSIX::setlocale) and locale related environment variables for diagnostics.

(this is something that I intend to do myself, but that may take months because of my lack of tuits)

-- 
Olivier Mengué - http://perlresume.org/DOLMEN
Here is some C code to check if the issue comes directly from nl_langinfo(CODESET) .

-- 
Olivier Mengué - http://perlresume.org/DOLMEN
Subject: codeset.c
Download codeset.c
text/x-csrc 533b
/* cc -o codeset codeset.c */ #include <stdio.h> #include <stdlib.h> #include <locale.h> #include <langinfo.h> void print_codeset(const char *locale_name) { printf("locale=%s\nCODESET=%s\n", locale_name, nl_langinfo(CODESET)); } int main() { const char *locale; printf("LC_ALL=%s\nLC_CTYPE=%s\n\n", getenv("LC_ALL"), getenv("LC_CTYPE")); locale = setlocale(LC_CTYPE, NULL); print_codeset(locale); puts("\nUsing locale...\n"); locale = setlocale(LC_CTYPE, ""); print_codeset(locale); }
Le 2015-10-21 17:18:33, DOLMEN a écrit :
Show quoted text
> perl -w '-MEncode 2.05' -mencoding -e 'print encoding::_get_locale_encoding, $/'
> 646

646 refers to ISO/IEC 646 which is similar to ASCII
https://en.wikipedia.org/wiki/ISO/IEC_646

Encode is already aware of this:
perl -MEncode=find_encoding -E 'say find_encoding("646")->name'
ascii

So _get_locale_encoding in Encode 2.73+ will properly return 'ascii'.


-- 
Olivier Mengué - http://perlresume.org/DOLMEN
Le 2015-10-21 17:18:33, DOLMEN a écrit :
Show quoted text
>
> So the next step would be to add a test that checks
> encoding::_get_locale_encoding returns either undef or the name of an
> encoding
> known to Encode.
> That test would also dump the result of langinfo, the current locale
> (POSIX::setlocale) and locale related environment variables for
> diagnostics.
>
> (this is something that I intend to do myself, but that may take
> months because
> of my lack of tuits)

I have a very bad memory.
I have already written this test myself some months ago and it is in the Encode distribution:
https://github.com/dankogai/p5-encode/blob/master/t/encoding-locale.t

So I'm closing the issue.

-- 
Olivier Mengué - http://perlresume.org/DOLMEN


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.