• Error with MD5

    From meshparts@alexandru.dadalau@meshparts.de to comp.lang.tcl on Tue Aug 25 09:07:14 2026
    From Newsgroup: comp.lang.tcl

    On Tcl 9.0.2 I gen an error with md5 function:

    ::md5::md5 -hex {+#=20-#}

    Error:

    expected byte sequence but character 0 was '+#=20-#' (U+0003B1)

    Can anyone help with this?

    Many thanks
    Alex
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From meshparts@alexandru.dadalau@meshparts.de to comp.lang.tcl on Tue Aug 25 09:30:02 2026
    From Newsgroup: comp.lang.tcl

    Am 25.08.2026 um 09:07 schrieb meshparts:
    On Tcl 9.0.2 I gen an error with md5 function:

    ::md5::md5 -hex {+#=20-#}

    Error:

    expected byte sequence but character 0 was '+#=20-#' (U+0003B1)

    Can anyone help with this?

    Many thanks
    Alex

    Tcl 8.6.12 works with this example.
    Is this a bug in Tcl 9?
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Christian Gollwitzer@auriocus@gmx.de to comp.lang.tcl on Tue Aug 25 12:13:06 2026
    From Newsgroup: comp.lang.tcl

    Am 25.08.26 um 09:30 schrieb meshparts:
    Am 25.08.2026 um 09:07 schrieb meshparts:
    On Tcl 9.0.2 I gen an error with md5 function:

    ::md5::md5 -hex {+#=20-#}

    Error:

    expected byte sequence but character 0 was '+#=20-#' (U+0003B1)

    Can anyone help with this?

    Many thanks
    Alex

    Tcl 8.6.12 works with this example.
    Is this a bug in Tcl 9?

    No, it is a bug in 8.6.

    MD5 works on bytesreams. When you feed it characters outside the byte
    range 0x00-0xFF, it is not defined. Most probably you want to encode the string as utf8 via [encoding convertto utf-8 $string].

    I believe 8.6 simply cuts off the higher unicode points modulo 0x100 or
    the like, which is why the this was changed in 9.0

    https://www.magicsplat.com/tcl9/tcl9unicode.html#binary-strings

    Christian
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From meshparts@alexandru.dadalau@meshparts.de to comp.lang.tcl on Tue Aug 25 14:58:55 2026
    From Newsgroup: comp.lang.tcl

    Am 25.08.2026 um 12:13 schrieb Christian Gollwitzer:
    Am 25.08.26 um 09:30 schrieb meshparts:
    Am 25.08.2026 um 09:07 schrieb meshparts:
    On Tcl 9.0.2 I gen an error with md5 function:

    ::md5::md5 -hex {+#=20-#}

    Error:

    expected byte sequence but character 0 was '+#=20-#' (U+0003B1)

    Can anyone help with this?

    Many thanks
    Alex

    Tcl 8.6.12 works with this example.
    Is this a bug in Tcl 9?

    No, it is a bug in 8.6.

    MD5 works on bytesreams. When you feed it characters outside the byte
    range 0x00-0xFF, it is not defined. Most probably you want to encode the string as utf8 via [encoding convertto utf-8 $string].

    I believe 8.6 simply cuts off the higher unicode points modulo 0x100 or
    the like, which is why the this was changed in 9.0

    https://www.magicsplat.com/tcl9/tcl9unicode.html#binary-strings

    -a-a-a-a-a Christian
    Many thanks Christian.
    I'll put that encoding command in there and see what happens.
    Alex
    --- Synchronet 3.22a-Linux NewsLink 1.2