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

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

Re: Byte offset from point


From: Eli Zaretskii
Subject: Re: Byte offset from point
Date: Wed, 12 Aug 2009 22:47:39 +0300

> From: senny <yves.senn@gmail.com>
> Date: Wed, 12 Aug 2009 12:06:26 -0700 (PDT)
> 
> >     (position-bytes (point))
> 
> I tried that but it gave me incorrect results when dealing with
> newlines on windows. The lisp function counted them as 1 byte but the
> service i was calling counted them as 2 bytes.

If you want Emacs to account for the (potentially stripped) CR
characters, you need to visit the file without any code conversions,
e.g. with `find-file-literally' or with
`insert-file-contents-literally'.  Then position-bytes will count
correctly.

Alternatively, you could call count-lines-region and add one character
for each line before point.

If this does not help, perhaps consider telling more about the problem
you are trying to solve.





reply via email to

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