Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Why is utf8 flag set after Encode::decode of pure ASCII?

by moritz (Cardinal)
on Mar 29, 2010 at 18:34 UTC ( #831677=note: print w/replies, xml ) Need Help??


in reply to Why is utf8 flag set after Encode::decode of pure ASCII?

The UTF-8 flag is meant to be purely internal - asking about its value in your Perl code and making decisions based on that information is bound to get you in trouble.

Still if the documentation says it should be off, it should probably be updated.

Perl 6 - links to (nearly) everything that is Perl 6.
  • Comment on Re: Why is utf8 flag set after Encode::decode of pure ASCII?

Replies are listed 'Best First'.
Re^2: Why is utf8 flag set after Encode::decode of pure ASCII?
by brycen (Monk) on Mar 30, 2010 at 18:32 UTC
    Many people give such advice: ignore perl's internal encoding. Fine advice, at least in production. But Perl makes so many magic behind-the-scenes Unicode conversions, one often needs to look at this flag in order to understand what end is up during development. Grr.

      It's not just Perl -- it's also CPAN modules, particularly XS modules. And I agree -- it's foolhardy to pretend that the SVf_UTF8 flag doesn't exist. It's almost impossible to troubleshoot UTF-8 problems in a large system without snooping it. The system is prone to silent failure, and when something goes wrong and you need to track down where the silent failure originates, you need to look at that flag.

      (Die $YAML::Syck::ImplicitUnicode, die die die.)

      Agreed, but it's the only sane advice you will get.

      The reasons you have to look at the utf8 flag sometimes is because some of the code (mostly CPAN modules) do not use the provided sane advice.

      If you want to read/write text in a portable manner, or convert between text and binary (integer) representation of characters, you have to specify what encoding you're expecting. If you don't, your code will only reliably work on 7bit ASCII text. And that'll only work on most platforms. That's the executive summary, and that's really all there is to it.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (5)
As of 2023-09-30 09:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?