Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Re: ASCII, Unicode, use utf8: My Story of Discovery

by richardX (Pilgrim)
on Nov 04, 2002 at 04:13 UTC ( #210118=note: print w/ replies, xml ) Need Help??

in reply to ASCII, Unicode, use utf8: My Story of Discovery

I have had my log parsing routines crash because of invalid ASCII characters, so I run this code against it, which cleans up the bad boys found.

# loop through the file zapping the bad characters found while(<FILE>) { $lineBuff = $_; # remove upper ascii $lineBuff =~ s/([\x7F-\xFF]+)/$delimiter/gm; # remove lower ascii $lineBuff =~ s/([\x00-\x1F]+)/$delimiter/gm; $lineBuff =~ s/\%//gm; # send the clean data to the output file print OUT "$lineBuff\n"; }


There are three types of people in this world, those that can count and those that cannot. Anon

Comment on Re: ASCII, Unicode, use utf8: My Story of Discovery
Download Code

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (5)
As of 2015-10-10 18:32 GMT
Find Nodes?
    Voting Booth?

    Does Humor Belong in Programming?

    Results (257 votes), past polls