Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Unexpected utf8 in hash keys

by kappa (Chaplain)
on Feb 20, 2008 at 11:27 UTC ( [id://668988]=note: print w/replies, xml ) Need Help??


in reply to Unexpected utf8 in hash keys

Fat comma is really at fault:
use utf8; sub ff { die if utf8::is_utf8($_[0]); } ff(asd => 1);
--kap

Replies are listed 'Best First'.
Re^2: Unexpected utf8 in hash keys (encoding)
by ikegami (Patriarch) on Feb 20, 2008 at 12:57 UTC

    encoding produces the opposite result.

    #use encoding 'UTF-8'; # or 'utf8' #use utf8; use Encode qw( is_utf8 ); sub ff { print is_utf8($_[0]) ? 1 : 0, "\n"; } # none enco utf8 both # ---- ---- ---- ---- ff("asd"); # 0 1 0 1 ff('asd'); # 0 1 0 1 ff(qw(asd)); # 0 1 0 1 ff(asd => 1); # 0 0 1 1 { no strict; ff(asd); } # 0 0 1 1 ff(-asd); # 0 0 1 1 ff(asd::); # 0 0 1 1
Re^2: Unexpected utf8 in hash keys (force_word)
by ikegami (Patriarch) on Feb 20, 2008 at 12:45 UTC

    After some investigation, barewords in general (anything parsed by force_word) are affected.

    use utf8; sub ff { print utf8::is_utf8($_[0]) ? 1 : 0, "\n"; } ff("asd"); # 0 ff('asd'); # 0 ff(qw(asd)); # 0 ff(asd => 1); # 1 { no strict; ff(asd); } # 1 ff(-asd); # 1 ff(asd::); # 1

    I think function names (including built-ins) and keywords are also affected.

    Gotta go. No time to devise a fix atm.

Re^2: Unexpected utf8 in hash keys (bug)
by ikegami (Patriarch) on Feb 20, 2008 at 12:03 UTC

    I'd expect both of the following calls to output the same thing, so I think it's a bug.

    use utf8; sub ff { print utf8::is_utf8($_[0]) ? 1 : 0, "\n"; } ff(asd => 1); # 1 ff("asd"); # 0

    Tested in 5.8.8 and 5.10.0.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (3)
As of 2024-04-25 22:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found