Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re^2: Mixed Unicode and ANSI string comparisons?

by Anonymous Monk
on Dec 15, 2015 at 00:51 UTC ( [id://1150311]=note: print w/replies, xml ) Need Help??


in reply to Re: Mixed Unicode and ANSI string comparisons?
in thread Mixed Unicode and ANSI string comparisons?

Why do you have both use open OUT => ':utf8', ':std'; and  map encode('utf-8', $_), @strings;?

Replies are listed 'Best First'.
Re^3: Mixed Unicode and ANSI string comparisons?
by Anonymous Monk on Dec 15, 2015 at 01:01 UTC
    Because without open perl would try to downgrade "$_: ", and warn that it can't do it for some strings ("wide character ...")

      Because without open perl would try to downgrade "$_: ", and warn that it can't do it for some strings ("wide character ...")

      Hmm, I guess I got confused by docs for open, made me think it did  binmode STDOUT, ':encoding(utf8)'; instead of  binmode STDOUT, ':utf8'; and/or that the two were the same, that both did encode, so the strings would be corrupted/double encoded,

      perlunitut explains they :utf8 and :encoding(:utf8) aren't the same

      But looking at source of open leads me to think it does :utf8 even if you write :encoding(:utf8)

      yeah, unicrap headache *sigh* :D

        Hmm, not sure what you're talking about
        perlunitut explains they :utf8 and :encoding(:utf8) aren't the same
        As far as i can tell they're pretty much the same... OTOH, :encoding(utf-8) and :encoding(utf8) are not. I also don't agree with perlunitut that encoding(utf-8) is interchangeable with :utf8. It was written almost 10 years ago. binmode has better advice:
        To mark FILEHANDLE as UTF-8, use ":utf8" or ":encoding(UTF-8)". ":utf8" just marks the data as UTF-8 without further checking, while ":encoding(UTF-8)" checks the data for actually being valid UTF-8.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (6)
As of 2024-04-23 15:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found