Beefy Boxes and Bandwidth Generously Provided by pair Networks Bob
There's more than one way to do things
 
PerlMonks  

Re: Removing Non-Ascii chars from text file

by zentara (Archbishop)
on Jun 07, 2007 at 12:22 UTC ( #619794=note: print w/ replies, xml ) Need Help??


in reply to Removing Non-Ascii chars from text file

Look at how this works.

#!/usr/bin/perl $s .= chr for 1..255; print $s,"\n\n"; $s =~ tr/\x20-\x7f//cd; print $s,"\n\n";

I'm not really a human, but I play one on earth. Cogito ergo sum a bum


Comment on Re: Removing Non-Ascii chars from text file
Download Code
Re^2: Removing Non-Ascii chars from text file
by Anonymous Monk on Nov 19, 2012 at 08:34 UTC
    ^\x20-\x7E This is not ASCII, this is real ascii: ^\x00-\x7F Otherwise it will trim out newlines and other special characters that are part of ascii table!

      <c> ^\x20-\x7E <c> This is not ASCI

      Sure it is, 32 through 126 (precisely all the characters that aren't 32 through 126 )

      Correct. ASCII "includes definitions for 128 characters: 33 are non-printing control characters... and 95 printable characters..."
      See this scanned copy of the original "American Standard Code for Information Interchange (ASCII)" from 1963, the 5th page in particular. This definition is also enshrined in Internet RFC 20.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (12)
As of 2014-04-17 08:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (441 votes), past polls