|
From: | Stefan Monnier |
Subject: | Re: Question: estimating size of a buffer when written to file? |
Date: | Wed, 08 Dec 2021 12:03:07 -0500 |
User-agent: | Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
> Is there any reliable way to get (or conservatively estimate) > the size of a buffer when written to file? How 'bout your first encode the buffer's content and then write it instead of relying on the write to do the encoding? This way you get to see the size trivially. If you need this estimate faster (e.g. because you may end up not writing the text at all depending on the result), then I think the only way is to multiply the number of chars by the amplification factor that is a property of the encoding (this is used in the C to allocate a destination byte-array that's guaranteed to be large enough. Not sure if we currently expose it to ELisp but it would be easy to do). Stefan
[Prev in Thread] | Current Thread | [Next in Thread] |