extended ascii problem

hi i would like to check text files if they contain extended ascii characters within or not. i really dont have any idea how to start your kind help would be very much appreciated thanks.

Get some introduction into regular expressions.

In regular expressions (regexps) there exists the possiblity of targeting "classes" of characters: [a-z] would, for instance, mean any character from a to z, that would resemble every smallcap character. If you would want to include the capital characters too, you would write "[a-zA-Z]".

You will find more of these classes in a manual.

bakunin

thanks ill dig into that :wink:

if you want to implement a small python script you could do something like this:

def findExtended(line):
    for f in line:
        if ord(f) > ord('\x7f'):
            return True
    return False

f = file('chars','r')

line = f.readline()

while line:
    if findExtended(line):
        print "found"
        break
    line = f.readline()

f.close()

This might not be the fastest way around, but it works.

for extended ASCII characters you could do a small check like this,

open(FILE, "<", $filename ) or die "Unable to open file $filename <$!> \n";

while ( read( FILE, $data, 1) == 1 ) {
  print "$data\n" if ( ord($data) > 128 );
}

close(FILE);

Hi.

Perhaps we can help you better if you tell us what you would do if and when you find extended ASCII characters in a file. Make a list of the files? Delete the file? Delete characters? Replace characters? ... cheers, drl

thanks for the help guys, problem now is i dont have python on the system im using. with regards to why and what i would do to the files. those text files i want to check are actually an output of a conversion process, a .STDF file to text file. at times after conversion some corruption would occur and those extended ascii's would appear. the conversion is done in batch and it takes time to finish. to save time i wish to filter out those good converted files and just reconverted those corrupted. cheers !

do you have perl installed ?

if so, try the code I had posted :slight_smile: