Is there a tool that can scan a small text file and look for any character not in the simple ASCII character set?
A simple Java or Groovy script would also do.
|
Well, it's still here after an hour, so I may as well answer it. Here's a simple filter that prints only non-ASCII characters from its input, and gives exit code 0 if there weren't any and 1 if there were. Reads from standard input only.
|
|||
|
Just run $JDK_HOME/bin/native2ascii on the text file and search for "\u" in the output file. I'm assuming you want to find it so you can escape it anyway and this will save you a step. ;) |
|||
|
|
|
I have no idea if this is legit, casting each char to an int and using a catch to identify things that fail. I'm also too lazy to write this in java so have some Groovy
==> Ã Â ç Ð |
|||
|
|
|
In Java (assuming the string is specified as the first command-line argument:
To make this your own, replace |
|||
|
|
|
A simple groovy example:
It's as simple as this bit here: Edit: I forgot to include a version for files. Oops:
That version can be used as a command line script, and includes an exit status so it can be chained. |
|||||||||||
|
grepwith a negated character class. – Tom Zych Aug 31 '11 at 0:59grep '[^\x00-\xFF]'or its moral equivalent using existing tools not writing a new program is nothing but insane overkill. – tchrist Aug 31 '11 at 2:17