A piggy bank of commands, fixes, succinct reviews, some mini articles and technical opinions from a (mostly) Perl developer.

Jump to

Quick reference

Showing posts with label ascii. Show all posts
Showing posts with label ascii. Show all posts

Find dodgy characters in a file

This will print any characters with values higher than 127, i.e. non-ascii characters that might look like ascii, but really be breaking your processor.

perl -lne'while (my ($c) = $_ =~ m{^(.)}) { print "$c = ".ord($c) if ord($c) > 127; $_ =~ s/^.// }' file_to_check.something


A quick, manual way to confirm some characters really are what you think they are:

cat file_to_check.something | od -bc

Check for non-ascii characters

perl -lne'until (! $_) { s/^(.)//; $c = $1; print $_ if ord($c) > 127 }' file.html

See hex dump of file on Linux or Mac

hexdump -C [file]

or

cat [file] | xxd