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

Re: Malformed UTF-8 character Error

by ikegami (Pope)
on May 11, 2010 at 23:25 UTC ( #839519=note: print w/replies, xml ) Need Help??

in reply to Malformed UTF-8 character Error

UPDATE: I'd really just be interested in skipping line if it is not UTF-8, or not dealing with these lines at all.

Do you realize that you'd be skipping all four lines you posted since none are valid UTF-8?

It's easy to do:

use strict; use warnings; use open ':std', ':locale'; use Encode qw( ); my $log = 'log'; open(my $fh, '<:raw:perlio', $log) or die("Can't open log file \"$log\": $!\n"); while (<$fh>) { s/\r?\n\z//; my $data = (split(/ /, $_, 4))[3]; my ($text) = eval { decode("UTF-8", $data, Encode::FB_CROAK) } or next; print($text); }

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://839519]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (5)
As of 2018-01-24 11:49 GMT
Find Nodes?
    Voting Booth?
    How did you see in the new year?

    Results (258 votes). Check out past polls.