(when (zerop (elt data i))
(setf (aref stats (mod i 2))
(1+ (aref stats (mod i 2))))))
- ;; If we have more than 90% every-other nul, then it's
- ;; pretty likely to be utf-16.
- (cond
- ((> (if (zerop (elt stats 1))
- 1
- (/ (float (elt stats 0))
- (float (elt stats 1))))
- 0.9)
- ;; Big endian.
- 'utf-16-be)
- ((> (if (zerop (elt stats 0))
- 1
- (/ (float (elt stats 1))
- (float (elt stats 0))))
- 0.9)
- ;; Little endian.
- 'utf-16-le))))))
+ ;; We have some nuls...
+ (and (not (and (zerop (elt stats 0))
+ (zerop (elt stats 1))))
+ ;; If we have more than 90% every-other nul, then it's
+ ;; pretty likely to be utf-16.
+ (cond
+ ((> (if (zerop (elt stats 1))
+ 1
+ (/ (float (elt stats 0))
+ (float (elt stats 1))))
+ 0.9)
+ ;; Big endian.
+ 'utf-16-be)
+ ((> (if (zerop (elt stats 0))
+ 1
+ (/ (float (elt stats 1))
+ (float (elt stats 0))))
+ 0.9)
+ ;; Little endian.
+ 'utf-16-le)))))))
(if coding-system
(decode-coding-string data coding-system)
;; Some programs add a nul character at the end of text/*