Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^2: question about Encode::decode('iso-8859-1', ...)

by perl5ever (Pilgrim)
on Mar 07, 2009 at 02:23 UTC ( [id://749004]=note: print w/replies, xml ) Need Help??


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

thanks, but do you mean "may return 0 ..." instead of "may return 1 ..." ?
  • Comment on Re^2: question about Encode::decode('iso-8859-1', ...)

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

    Well, it can return both :)

    It can return zero for any encoding other than US-ASCII and 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.

        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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://749004]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (4)
As of 2024-04-16 10:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found