[NTG-context] new hash for buffer (as file)

Pablo Rodriguez oinos at gmx.es
Fri Sep 23 17:06:45 CEST 2022

On 9/23/22 06:01, Max Chernoff via ntg-context wrote:
> […]
> The SHA calculation isn't working properly because of a weird newline
> issue. Try this:
> […]
>        function sha256(str)
>            return utilities.sha2.hash256(
>                str:gsub(string.char(0x0D), string.char(0x0A))
>            )
>        end
> […]

Hi Max,

this works perfectly fine with Linux "str:gsub('\r','\n')", but I can’t
make it work in Windows.

I always thought that Unix used LF (\n, if I’m not wrong) to mark a new
line, and Windows used CRLF (\r\n).

How are new lines marked in the buffer? As \r instead of \r\n or \n?

At least, Notepad (the minimal plain text editor in Windows) doesn’t
recognize newlines if I attach the buffer to the PDF document as a .txt

Many thanks for your help,


More information about the ntg-context mailing list