Jens Lechtenboerger <[email protected]> writes:
> On 2023-02-20, Bruno Barbier wrote:
>
> However, if I use insert-file-contents-literally with a unicode
> file, I do *not* have to set the coding-system-for-write. This just
> works:
>
> (with-temp-buffer
> (insert-file-contents-literally "~/unicode.org")
> (secure-hash 'md5 (current-buffer)))
Humm. Emacs is amazing: it managed to guess the right encoding, from the
buffer context, probably...
But, what you are giving to 'org-export-string-as' is not the buffer,
it's a string. So, let's try the same without using an org function:
(with-temp-buffer
(insert (with-temp-buffer
(insert-file-contents-literally "~/unicode.org")
(buffer-string)))
(secure-hash 'md5 (current-buffer)))
And, that fails, requesting an encoding.
> In the context of Org export, secure-hash seems to require a coding
> system. Why?
I'm not an expert, so, you'll need to confirm with other sources. But
secure-hash requires an encoding in all cases, to compute the hash of
some text, because it needs the array of bytes that represents that text
to compute its hash.
I don't see any bug in org, and, I don't see any bug in secure-hash either.
You literally shoud stop using "literally" ;-)
And, you might want to read:
(info "(elisp) Non-ASCII Characters")
Bruno
>
> Best wishes
> Jens