in reply to Re^3: question about Encode::decode('iso-8859-1', ...)
in thread question about Encode::decode('iso-8859-1', ...)

Don't think so. Could you provide an example?

For "any encoding other than US-ASCII and iso-8859-1" to matter while decoding, you'd need wide characters, in which case Perl will croak with "Wide character in subroutine entry at .../Encode.pm line..." before returning anything. Any non-wide characters will simply be treated as iso-8859-1, because decode('iso-8859-1',...) is telling Perl they are.

Replies are listed 'Best First'.
Re^5: question about Encode::decode('iso-8859-1', ...)
by ikegami (Patriarch) on Mar 07, 2009 at 12:36 UTC

    Here's a test that works with single-byte encodings:

    >perl -MEncode -wle"for (0..255) { print if chr ne decode($ARGV[0], ch +r) }" iso-8859-1 >perl -MEncode -wle"for (0x20..0x7E,0x0A..0xFF) { print if chr ne deco +de($ARGV[0], chr) }" iso-8859-2 161 162 163 165 166 169 ...

    Here's a UTF-8 example:

    >perl -MEncode -wle"$chr=qq{\342\231\240}; print 'diff' if $chr ne dec +ode('UTF-8', $chr)" diff

      Yes, but that's not what the question was. It was asked whether there is any value of $x for which test($x) with the given code (i.e. decode('iso-8859-1',...)) returns 0.  By modifying the code you can of course achieve anything...  But this is kind of like

      "Is there any case in which this code will return 0?"

      sub test { if (1) { return 1; } else { retrun 0; } }

      Yes, there is:

      sub test { if (0) { return 1; } else { retrun 0; } }

        Are you saying it isn't reasonable for by borisz and I to think the OP and other readers would be interested in other encodings? It's funny how you have a problem with it, but the OP doesn't seem to.