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

Re: Using pragma utf8::all in processing non-utf data.

by remiah (Hermit)
on Sep 04, 2013 at 09:01 UTC ( #1052262=note: print w/replies, xml ) Need Help??

in reply to Using pragma utf8::all in processing non-utf data.

Hello humble and monks.

As daxim says, utf8::all dies because it imports its setting to your current code. In this case, "use warnings FATAL =>'utf8'" is imported from utf8::all and it dies. Below dies with utf8::all.

print "before shiftjis\n"; open( my $fh, "<", "107.shiftjis.txt") or die $!; print join('', <$fh>); close $fh;
If you disable "use warnings FATAL =>'utf8'" temporally, I guess you will not die.
use warnings NONFATAL =>'utf8'; #disable print "before shiftjis\n"; open( my $fh, "<", "107.shiftjis.txt") or die $!; print join('', <$fh>); close $fh; "use warnings FATAL =>'utf8'"; #enable

Replies are listed 'Best First'.
Re^2: Using pragma utf8::all in processing non-utf data.
by daxim (Chaplain) on Sep 04, 2013 at 14:34 UTC
    Just unfataling or disabling the warning makes no sense. The :encoding(UTF-8) IO layer will still be active and the readline function will produce garbage input.

      Hello daxim.

      As you says, we have to detect it's encode and decode its 'characters' into perl's internal encoding. ":pop" will give you un-encoded $fh. It also makes no sense.

      And one more for utf8:all. Please refer its problem in this thread "How can I safely unescape a string.". After all, utf8:all never frees you from encoding troubles.


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1052262]
[stevieb]: did my pull request challenge today, Locale::gettext. Weird layout for a dist, and I have no idea how to use it, but it's always nice when you can force someone else's work be use strict; and use warnings; compliant :)
[stevieb]: ahem... s/no idea how to use it/didn't read enough as to what it's used for/
[stevieb]: interestingly enough, someone else got my Devel::Examine:: Subs distribution for their PRC, and I applaud the change. This dist is extremely complicated and mostly obfu, but the person doing it understood PPI enough to change...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (4)
As of 2017-01-24 01:14 GMT
Find Nodes?
    Voting Booth?
    Do you watch meteor showers?

    Results (199 votes). Check out past polls.