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

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

Replies are listed 'Best First'.
Re^6: question about Encode::decode('iso-8859-1', ...)
by Anonymous Monk on Mar 07, 2009 at 12:58 UTC

    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.