Skip to content
Tcl Source Code History Of Ticket 8e1e31eac0fd6b6c
Login

History Of Ticket 8e1e31eac0fd6b6c

Artifacts Associated With Ticket 8e1e31eac0fd6b6c

  1. Ticket change [9d2081a06d] (rid 155217) by m7j4k9 on 2017-07-20 10:21:46:

    1. assignee initialized to: "nobody"
    2. closer initialized to: "nobody"
    3. cmimetype initialized to: "text/plain"
    4. comment initialized to:
      The NUL character is not collated correctly.
      
      The Tcl command below demonstrates that the NUL character 
      is treated by lsort as if it had the bit value 0111 1111.1
      -- that's right, as if it were between 127 and 128.
      
      % join [lsort [list \0.1 \7.2 a.3 z.4 \x7F.5 \x80.6 \xFF.7]] :
      
      .2:a.3:z.4:.5: .1:€.6:ÿ.7
      
      Only NUL seems to be treated this oddly as confirmed by:
      
      % for { set list {} ; set i 0 } { $i < 256 } { incr i } { lappend list [format %c.%02x $i $i] }
      % lsort $list
      
    5. foundin initialized to: "8.6.6"
    6. is_private initialized to: "0"
    7. login: "m7j4k9"
    8. priority initialized to: "5 Medium"
    9. private_contact initialized to: "19f06fe5054ecb07284f096bd2da5fdc29221e4e"
    10. resolution initialized to: "None"
    11. severity initialized to: "Minor"
    12. status initialized to: "Open"
    13. submitter initialized to: "m7j4k9"
    14. subsystem initialized to: "17. Commands I-L"
    15. title initialized to: "lsort treats NUL chars strangely"
    16. type initialized to: "Bug"
  2. Ticket change [1445f8fa9a] (rid 155218) by sebres on 2017-07-20 14:35:20:

    1. closedate changed to: "2457955.10787487"
    2. closer changed to: "sebres"
    3. icomment:
      Shortly: use the option <code>-dictionary</code> by <code>lsort</code>.
      
      In Tcl the string <code>"\0"</code> is an utf-8 sequence c080 hex...
      See for example <code>expr {"\0" eq [encoding convertfrom utf-8 \xc0\x80]}</code>
      This going to special handling (resp. special utf-8 table) within Tcl to differentiate between zero-byte and zero-NTS-character.
      
      But <code>lsort</code> (without <code>-dictionary</code>) will do that not for zero-char, but for all other non-ascii charaters also (e. g. umlauts, etc.).
      
      Possibly following example can help you to do the sorting using byte-comparision...
      <pre><code>
      % lsort [list "\0 1" "\x7F 2" "\x80 3"]
      {⌂ 2} {  1} {? 3}
      % lsort -dictionary [list "\0 1" "\x7F 2" "\x80 3"]
      {  1} {⌂ 2} {? 3}
      % proc sortbybyte {a b} {expr {[scan $a %c] - [scan $b %c]}}
      % lsort -command sortbybyte -index 0 [list "\0 1" "\x7F 2" "\x80 3"]
      {  1} {⌂ 2} {? 3}
      </code></pre>
      
      @TCT, @Jan: should we handle the default sorting algorithm to take into account this byte-sequence, so it will be sorted as first char in utf-8?<br/>
      I think not...
      
    4. login: "sebres"
    5. mimetype: "text/x-fossil-wiki"
    6. resolution changed to: "Invalid"
    7. status changed to: "Closed"
  3. Ticket change [b720f7c16e] (rid 158991) by jan.nijtmans on 2017-11-29 09:53:54:

    1. assignee changed to: "jan.nijtmans"
    2. closer changed to: "nobody"
    3. icomment:
      It turns out that for TCL_UTF_MAX == 4 (TIP #389) we need to handle the surrogate pair situation especially anyway, so we cannot escape to introduce a new internal TclStrcmp() function. Doing that, we automatically handle this bug at the same time.
      
      So, I'm on it ....
      
      It's fixed now in the "tip-389" branch. Probably not worth to fix this for 8.6.
      
    4. login: "jan.nijtmans"
    5. mimetype: "text/x-fossil-wiki"
    6. resolution changed to: "None"
    7. status changed to: "Open"
  4. Ticket change [f052dbe4b6] (rid 159092) by jan.nijtmans on 2017-11-30 13:15:57:

    1. closedate changed to: "2458088.05274933"
    2. closer changed to: "jan.nijtmans"
    3. icomment:
      Now fixed in core-8-branch. Will be in Tcl 8.7.0.
      
      Not worth to backport to 8.6.
      
    4. login: "jan.nijtmans"
    5. mimetype: "text/plain"
    6. resolution changed to: "Fixed"
    7. status changed to: "Closed"
  5. Ticket change [a3046bdbe0] (rid 185476) by oehhar on 2020-08-11 14:57:09:

    1. closedate changed to: "2459073.12302219"
    2. closer changed to: "oehhar"
    3. icomment:
      May I propose to document this in the tcl 8.6 documentation?
      
      As the NUL->\xc080 is not exposed to the script level normally, at least a documentation would be great.
      
      Thank you,
      Harald
      
    4. login: "oehhar"
    5. mimetype: "text/x-fossil-wiki"
    6. username: "oehhar"