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: Fri, 23 Aug 2024 00:37:33 -0700

Eli Zaretskii <eliz@gnu.org> writes:

>> From: Joseph Turner <joseph@ushin.org>
>> Cc: emacs-devel@gnu.org,  schwab@suse.de,  adam@alphapapa.net
>> Date: Thu, 22 Aug 2024 20:56:19 -0700
>> 
>> Eli Zaretskii <eliz@gnu.org> writes:
>> 
>> >> For encoding text, should we encode with buffer-file-coding-system?
>> >
>> > If you are sure it will do, yes.  But what if the buffer started as
>> > all-ASCII and then the user or some Lisp program added some non-ASCII
>> > characters before saving?  Then buffer-file-coding-system is no longer
>> > pertinent.
>> 
>> I understand.  Thank you!
>> 
>> How do we encode if find-coding-systems-region returns '(undecided)?
>
> Use buffer-file-coding-system.
>
> If this is an interactive command, you could also use
> select-safe-coding-system, which calls find-coding-systems-region
> internally, and also has complex logic for finding suitable callbacks
> and asking the user to select an encoding if it fails to find
> something suitable.  But this is not appropriate in non-interactive
> code.

Thank you!  If both find-coding-systems-region and
buffer-file-coding-system are undecided, then is it safe to fallback to
utf-8?

I feel grateful for your thorough attention to this topic.

Joseph



reply via email to

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