[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: say if grep can find non-ascii
From: |
Paul Eggert |
Subject: |
Re: say if grep can find non-ascii |
Date: |
Tue, 07 Mar 2006 00:22:43 -0800 |
User-agent: |
Gnus/5.1007 (Gnus v5.10.7) Emacs/21.4 (gnu/linux) |
Julian Foad <address@hidden> writes:
> I don't think the Grep manual should say explicitly how to do that
> particular thing.
I disagree. I think it'd be useful to have a simple pattern that
tests for ASCII characters (i.e., bytes in the range 00 through 7F).
I myself needed such a pattern in the last couple of days, when I
mentioned to Andrew Josey of the Open Group that some of their
published text documents contained non-ASCII characters, and he
responded "How can I easily check for this?". I ended up telling him
"LC_ALL=C grep '[^[:space:][:print:]]'", which (1) is not quite
correct, and (2) is far less convenient than "grep '[[:ascii:]]'"
would be.
> I'm not sure what the definition of "ASCII" is in this case
The standard one. See <http://en.wikipedia.org/wiki/ASCII>.
> Does the following command do what you want?
>
> grep '[ -~]'
That isn't correct, first because it's not portable outside the C
locale, and second because it doesn't match the 33 ASCII control
characters.