perl-unicode

Re[4]: Encode::compat 0.01 says "Unsupported conversion"

2002-10-02 07:30:08
Hi,

On Tue, 1 Oct 2002, 10:07 GMT+08 (04:07 local time) Autrijus Tang
wrote:

On Wed, Sep 25, 2002 at 07:44:47PM +0200, Robert Allerstorfer wrote:
     my ($from, $to) = map { s/^utf8$/utf-8/i; lc($_) } ($_[1], $_[2]);
But this fails due to the attempt to change $_[1]. I fixed this by
replacing this line by

        my ($from, $to) = @_[1, 2];
        ($from, $to) = map {
                s/^utf8$/utf-8/i;
                s/^shiftjis$/shift_jis/i;
                lc;
        } ($from, $to);

Thanks for your input.  I decide to bundle the Alias.pm with Encode::compat 
to fix this problem more cleanly.

cool, but this produces encoding names that may not be supported by
iconv that is called by the Iconv module on some platforms. For
example, if the Perl code is

Encode::from_to($text, "sjis", "utf8");

Encode::compat would send "sjis" to Encode::Alias that comes back
with "shiftjis". On Windows, this results in an error due to an
Unsupported conversion because Iconv.dll does not know "shiftjis", but
it does know "sjis". "sjis" did work fine on several platforms that I
have tested so far.

Similary, I have found some limitations on certain platforms:

                s/^utf8$/utf-8/i unless $^O eq "hpux";
                # at least Win32 requires UTF-8 to be called 'utf-8'
                # On HP-UX, the encoding name for UTF-8 must be exactly 'utf8' 
(lowercase)
                s/^utf-8$/UTF-8/i if $^O eq "solaris";
                # On SunOS, the encoding name for UTF-8 must be exactly 'UTF-8' 
(UPPERcase)

                s/^ucs-2$/ucs2/i if $^O eq "hpux";
                # On HP-UX, the encoding name for UCS-2 must be exactly 'ucs2' 
(lowercase)
                s/^ucs-2$/UCS-2/i if $^O eq "solaris";
                # On SunOS, the encoding name for UCS-2 must be exactly 'UCS-2' 
(UPPERcase)

                s/^shiftjis$/sjis/i;
                s/^sjis$/SJIS/i if $^O eq "solaris";
                # On SunOS, the encoding name for Shift_JIS must be exactly 
'SJIS' (UPPERcase)
                lc unless $^O eq "solaris";

I used this code on Encode::compat 0.02 and will now have to fit it to
0.04. You have announced that you are planning to use Unicode::MapUTF8
instead of Text::Iconv in a future version. Will this add more
platform independency?

best,
rob.

<Prev in Thread] Current Thread [Next in Thread>