help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Checking for ASCII 7-bit Cleaness


From: Hallvard B Furuseth
Subject: Re: Checking for ASCII 7-bit Cleaness
Date: Tue, 09 Jun 2009 20:53:33 +0200
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.2 (gnu/linux)

Nordlöw writes:
> In C I would have stepped forward 4 bytes (except for the resting 1-3
> bytes of the file of course) and for each such block x then tested
> that (x & 0x80808080) equals zero. If so the file is 7-bit clean.
> Could we do something similar with elisp regular expression
> operations?

Don't think so.  That's a C internals trick, abusing how integers and
bytes are represented.

(defun buffer-ascii-clean-p ()
  (save-excursion
    (goto-char (point-min))
    (skip-chars-forward "[\0-\177]")
    (eobp)))

-- 
Hallvard


reply via email to

[Prev in Thread] Current Thread [Next in Thread]