emacs-pretest-bug
[Top][All Lists]
Advanced

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

Re: address@hidden: hexl-max-address in hexl-mode is incorrect]


From: Ye Wenbin
Subject: Re: address@hidden: hexl-max-address in hexl-mode is incorrect]
Date: Thu, 23 Nov 2006 08:42:05 +0800
User-agent: Opera Mail/9.01 (Linux)

Sorry, I made a mistaken. Should use encode-coding-string rather than decode-coding-string.

On Thu, 23 Nov 2006 00:02:22 +0800, Chong Yidong <address@hidden> wrote:

The hexl-max-address usually set to buffer-size, but when the buffer
contain a multiple byte character or the file associated to the buffer
is  encoded by multibyte coding system such as utf-16, the
hexl-max-address is  usually less the the real byte of buffer.

You can test like this:

Test case 2:
Open a new file, such as /tmp/test.txt. Use C-x RET f to set the file
coding system to utf-16. Input any letters such as "ab", and save the
buffer. Then change mode to hexl-mode. C-h v hexl-max-address show the
value is still 2 which is the buffer-size rather than the sizze of the
file.

Here is my solution to set hexl-max-address which might help:
(setq hexl-max-address
      (1- (if buffer-file-name
              (nth 7 (file-attributes buffer-file-name))
            (length
             (decode-coding-string (buffer-string)
buffer-file-coding-system)))))

The (nth 7 (file-attributes buffer-file-name)) method returns the
correct byte count.  However, the
(decode-coding-string (buffer-string) buffer-file-coding-system)
method doesn't seem to work for me; it returns erratic incorrect
results.  In the case of a utf-16 buffer containing just "ab" without
an associated file, it returns 1; if there is an associated buffer, it
returns 0.



--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/




reply via email to

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