emacs-devel
[Top][All Lists]
Advanced

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

Re: How to get buffer byte length (not number of characters)?


From: Joseph Turner
Subject: Re: How to get buffer byte length (not number of characters)?
Date: Sun, 25 Aug 2024 23:49:52 -0700

Joseph Turner <joseph@ushin.org> writes:

> Eli Zaretskii <eliz@gnu.org> writes:
>
>> you need to consider the encoding process: Emacs always encodes the
>> buffer text on output to the external world.  If this is what you
>> want, then you need to use bufferpos-to-filepos, and make sure you
>> pass the correct coding-system argument to it.
>
> Will the following code ever signal an error?
>
> (bufferpos-to-filepos
>  (point-max) 'exact
>  (select-safe-coding-system (point-min) (point-max)))
>
> The `bufferpos-to-filepos' docstring says, "It is an error to request
> the ‘exact’ method when the buffer’s EOL format is not yet decided."
>     
> IOW, does `select-safe-coding-system' always return an encoding which
> specifies EOL conversion?

Let me rephrase: I would like to get the size of a buffer's text encoded
with the return value of select-safe-coding-system, which may return an
encoding which does not specify EOL conversion.  Is there any way to
calculate the `exact' buffer text size using bufferpos-to-filepos?

Or is `approximate' the only viable argument in this case?

Thanks!

Joseph



reply via email to

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