On 9/23/22 17:06, Pablo Rodriguez via ntg-context wrote: > On 9/23/22 06:01, Max Chernoff via ntg-context wrote: >> […] >> return utilities.sha2.hash256( >> str:gsub(string.char(0x0D), string.char(0x0A)) >> ) > […] > this works perfectly fine with Linux "str:gsub('\r','\n')", but I can’t > make it work in Windows.
Hi again Max, this seems to solve the issue in Windows too: \startbuffer[test] just a test and another one \stopbuffer \starttext \startluacode require("util-sha") function sha256(str) if os.name == "windows" then return utilities.sha2.hash256(str:gsub("\r", "\r\n")) else return utilities.sha2.hash256(str:gsub("\r", "\n")) end end \stopluacode \def\shabuffer#1% {\cldcontext{sha256(buffers.raw("#1"))}} \def\shafile#1% {\cldcontext{utilities.sha2.hash256(io.loaddata("#1"))}} \shabuffer{test} \savebuffer[test][temporary-αβγ, prefix=no] \shafile{temporary-αβγ} \stoptext But now I don’t understand is the following issue: if the saved file contains "\r\n", why does basic Notepad the new lines? "\r\n" are the chars to get new lines in Windows. Or what am I missing here? Many thanks for your help, Pablo ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context webpage : https://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : https://contextgarden.net ___________________________________________________________________________________