Skip to content
Tcl Source Code History Of Ticket e617e8a71a00496e
Login

History Of Ticket e617e8a71a00496e

Artifacts Associated With Ticket e617e8a71a00496e

  1. Ticket change [671304cb32] (rid 182666) by dgp on 2020-04-27 21:14:27:

    1. assignee initialized to: "nobody"
    2. closer initialized to: "nobody"
    3. cmimetype initialized to: "text/plain"
    4. comment initialized to:
      ==== utf-25.5 Tcl_UniCharNcasecmp FAILED
      ==== Contents of test case:
      
      	teststringobj set 1 $one
      	teststringobj set 2 $two
      	teststringobj maxchars 1
      	teststringobj maxchars 2
      	set result [string compare -nocase [teststringobj get 1] [teststringobj get 2]]
      	if {$result eq [string map {< -1 = 0 > 1} $order]} {
      	    set result ok
      	} else {
      	    set result "'$one' should be $order '$two' (no case)"
      	}
      	set result
          
      ---- Result was:
      '￿' should be < '𐀀' (no case)
      ---- Result should have been (exact matching):
      ok
      ==== utf-25.5 FAILED
      
      
      
      ==== utf-25.6 Tcl_UniCharNcasecmp FAILED
      ==== Contents of test case:
      
      	teststringobj set 1 $one
      	teststringobj set 2 $two
      	teststringobj maxchars 1
      	teststringobj maxchars 2
      	set result [string compare -nocase [teststringobj get 1] [teststringobj get 2]]
      	if {$result eq [string map {< -1 = 0 > 1} $order]} {
      	    set result ok
      	} else {
      	    set result "'$one' should be $order '$two' (no case)"
      	}
      	set result
          
      ---- Result was:
      '￿' should be < '𐀀' (no case)
      ---- Result should have been (exact matching):
      ok
      ==== utf-25.6 FAILED
      
    5. foundin initialized to: "8.7"
    6. is_private initialized to: "0"
    7. login: "dgp"
    8. priority initialized to: "5 Medium"
    9. resolution initialized to: "None"
    10. severity initialized to: "Important"
    11. status initialized to: "Open"
    12. submitter initialized to: "dgp"
    13. subsystem initialized to: "44. UTF-8 Strings"
    14. title initialized to:
      comparing UTF-16 strings doesn't account for surrogates
      
    15. type initialized to: "Bug"
  2. Ticket change [c912054732] (rid 182790) by dgp on 2020-04-29 17:50:02:

    1. icomment:
      
      First attempt at a fix committed. It exposes trouble with the interface.
      
      The routine signature is
      
      Tcl_UniCharNcasecmp(const Tcl_UniChar *ucs, const Tcl_UniChar *uct, unsigned long numChars)
      
      The numChars argument name suggests we should count chars, but we've
      been counting UCS-2 code units.  As we enter a world where those are not
      the same thing, we have to re-specify what the argument should be taken to mean.
      
      If callers think of the argument as the number of UCS-2 code units, the length
      of sub-array, then the calls can stay unchanged, but when that number splits
      a character, we'll get nonsense results, as seen in this first attempt.
      
      We want to compare the character \uFFFF against the character \uD800\uDC00
      but the (numChars = 1) argument prevents us taking the low surrogate into account
      as we must do to get the right answer.
      
    2. login: "dgp"
    3. mimetype: "text/plain"
  3. Ticket change [cf69f7f4c7] (rid 182791) by dgp on 2020-04-29 17:55:37:

    1. icomment:
      
      Note that TIP 542 has deprecated this function.
      
    2. login: "dgp"
    3. mimetype: "text/plain"
  4. Ticket change [eb61088af8] (rid 182792) by dgp on 2020-04-29 18:05:36:

    1. icomment:
      
      So long as we stick to that deprecation, I should not be trying to fix this
      routine, but eliminating its use.
      
    2. login: "dgp"
    3. mimetype: "text/plain"
  5. Ticket change [8671b9ccdf] (rid 182805) by dgp on 2020-04-29 21:20:55:

    1. assignee changed to: "dgp"
    2. icomment:
      
      Tcl_UniCharNcmp() is also deprecated, and also has similar issues.
      
      % string compare \uFFFF\uFFFF \U10000\U10000
      -1
      % string compare [string repeat \uFFFF 2] [string repeat \U10000 2]
      1
      
    3. login: "dgp"
    4. mimetype: "text/plain"
  6. Ticket change [1517a02e77] (rid 182876) by dgp on 2020-04-30 18:23:27:

    1. icomment:
      
      Work continues on this in a branch, but it's worth noting that matters
      are confusing and difficult because routines and commands that by
      their names and documentation one expects to operate on characters
      are actually operating on UTF-16 code units.  For example, if I don't
      think very carefully about the implementation details, this result is
      surprising to me:
      
      % string compare -length 1 \U10000 \U10001
      0
      
      I think it would be surprising to anyone giving the docs for
      [string compare] a plain reading.
      
      My knee-jerk reaction is to want to revise 8.7 so indexing and lengths
      count characters and not code units, but I know that means a TIP,
      and I have to believe there were strong reasons not to do that in
      the first place.
      
      If we do not attempt something like that, though, we'll need to 
      improve the clarity of a lot of documentation on this point.
      
    2. login: "dgp"
    3. mimetype: "text/plain"
  7. Ticket change [43c29e23e3] (rid 182883) by dgp on 2020-04-30 19:12:48:

    1. icomment:
      
      According to the revised understanding that [string compare] operates
      and is defined on sequences of UTF-16 code units and not on sequences
      of characters, this bug is Not a Bug at all.
      
      \UFFFF is the one-unit string \uFFFF
      \U10000 is the two-unit string \uD800\uDC00
      
      and indeed the first sorts higher than the second.
      
      Expecting character comparisons is currently something that can only
      be done under constraint "ucs4".
      
      I'm not happy about that, but it seems to be the status of things now.
      
      I'm going to keep this ticket open, but it's now a different category of work.
      
    2. login: "dgp"
    3. mimetype: "text/plain"
    4. type changed to: "RFE"
  8. Ticket change [ecc384092c] (rid 193280) by jan.nijtmans on 2021-04-07 12:49:18:

    1. closedate changed to: "2459312.03424405"
    2. closer changed to: "jan.nijtmans"
    3. icomment: "Dup of [4c591fa487], which is fixed now."
    4. login: "jan.nijtmans"
    5. mimetype: "text/x-fossil-wiki"
    6. resolution changed to: "Fixed"
    7. status changed to: "Closed"
    8. type changed to: "Bug"