Skip to content
Tcl Source Code History Of Ticket 2bcf781c6c
Login

History Of Ticket 2bcf781c6c

Artifacts Associated With Ticket 2bcf781c6c

  1. Ticket change [28f90391d5] (rid 198489) by griffin on 2022-02-24 17:21:33:

    1. assignee initialized to: "nobody"
    2. closer initialized to: "nobody"
    3. cmimetype initialized to: "text/plain"
    4. comment initialized to:
      Strings with some multi-byte characters produce wrong size calculation results.  This effects string slicing, and in the severe case, cause Tk to crash with memory corruption.  The Tk crash can occur in an entry box, deleting characters one at a time. The following test case demonstrates incorrect string length results.
      
      
      set blocks {
          blank ⬜
          black ⬛
          yellow 🟨
          green 🟩    
      }
      
      set Ublocks {
          blank \U2B1C
          black \U2B1B
          yellow \U1F7E8
          green \U1F7E9
      }
      
      proc xlat {from blocks} {
          set to ""
          foreach f $from {
      	append to [dict get $blocks $f]
          }
          return $to
      }
      
      set s1 yellow
      puts "s1 = '$s1'"
      puts "string range s1 0 end-1 = '[string range $s1 0 end-1]'"
      set word [list yellow black yellow green green]
      set emoji [xlat $word $::Ublocks]
      puts "$word -> '$emoji'"
      puts "string length -> [string length $emoji]"
      puts "string length should be [llength $word]"
      set el [split $emoji {}]
      puts "split length is [llength $el]"
      puts "(joined slice of 0 end-1) = '[join [lrange $el 0 end-1] {}]'"
      set e2 [string range $emoji 0 end-1]
      puts "e2 (string slice 0 end-1) = '$e2'"
      puts "e2 string length -> [string length $e2]"
      puts "str len should be -> [expr {[llength $word]-1}]"
      
      set e3 [string range $emoji 0 end-2]
      puts "e3 (slice 0 end-2) = '$e3'"
      puts "e3 string length -> [string length $e3]"
      puts "str len should be -> [expr {[llength $word]-2}]"
      
      
      set s2 ""
      foreach k [dict keys $blocks] {
          scan [dict get $blocks $k] "%c" value
          append s2 [format "\\U%X" $value]
      }
      
    5. foundin initialized to: "core-8-branch"
    6. is_private initialized to: "0"
    7. login: "griffin"
    8. priority initialized to: "5 Medium"
    9. private_contact initialized to: "21780c4e03cc5884af69addd6efc1b71c50d9818"
    10. resolution initialized to: "None"
    11. severity initialized to: "Severe"
    12. status initialized to: "Open"
    13. submitter initialized to: "griffin"
    14. subsystem initialized to: "44. UTF-8 Strings"
    15. title initialized to:
      Incorrect size computed for some multi-byte UTF-8 characters
      
    16. type initialized to: "Bug"
  2. Ticket change [d073b4f13f] (rid 198679) by jan.nijtmans on 2022-03-03 08:08:28:

    1. icomment:
      Let's see, in Tcl 8.6:
      <pre>
      % string length 🟨
      2
      % llength [split 🟨 {}]
      1
      % string range 🟨 0 0
      ???
      % string range 🟨 1 1
      ???
      % string index 🟨 0
      ???
      % string index 🟨 1
      ???
      </pre>
      
      In Tcl 8.7:
      <pre>
      % string length 🟨
      2
      % llength [split 🟨 {}]
      1
      % string range 🟨 0 0
      🟨
      % string range 🟨 1 1
      % string index 🟨 0
      🟨
      % string index 🟨 1
      </pre>
      
      In Tcl 9.0:
      <pre>
      % string length 🟨
      1
      % llength [split 🟨 {}]
      1
      % string range 🟨 0 0
      🟨
      % string range 🟨 1 1
      % string index 🟨 0
      🟨
      % string index 🟨 1
      </pre>
      
      So, length calculations are equal in Tcl 8.6 and 8.7, there isn't - for sure - any bug there. In Tcl 8.7, 🟨 cannot be split into surrogates anymore, that's the main differences visible at script level. Where Tcl 8.6 gives nonsence results when trying to split emoji, Tcl 8.7 gives at least consistent results.
      
      When Tk crashes because of incorrect length calculations, that's a bug in Tk. In Tk things are more complicated, e.g:
      <pre>
      % string length πŸ˜Άβ€πŸŒ«οΈ
      6
      </pre>
      Many emoji consist of multiple Unicode codepoints. When pressing "delete", those all should be deleted. A solution for this in progress, the "glyph_indexing_2" branch. You will find (hopefully) that with Tcl 8.7 (or 9.0) in combination with Tk "glyph_indexing_2", this problem will be gone.
      
      So, I think this ticket should move to Tk, and "glyph_indexing_2" is a proposed solution. This branch works fine for the entry widget, there are still known problems with the text widget that still needs to be worked out.
      
      Hope this helps
      
    2. login: "jan.nijtmans"
    3. mimetype: "text/x-fossil-wiki"
  3. Ticket change [39abde5dae] (rid 198680) by jan.nijtmans on 2022-03-03 08:56:06:

    1. icomment:
      Maybe better example (since πŸ˜Άβ€πŸŒ«οΈ still doesn't show as 1 emoji on all browsers):
      <pre>
      % string length πŸ‘¨β€πŸ¦°
      5
      </pre>
      
    2. login: "jan.nijtmans"
    3. mimetype: "text/plain"
  4. Ticket change [fcaa54062d] (rid 200437) by jan.nijtmans on 2022-04-27 20:29:10:

    1. assignee changed to: "jan.nijtmans"
    2. login: "jan.nijtmans"
    3. mimetype: "text/plain"
  5. Ticket change [6e28ccb746] (rid 200438) by jan.nijtmans on 2022-04-27 20:34:49:

    1. icomment:
      Is this bug (as far as the cause is in Tcl) fixed with the [https://core.tcl-lang.org/tcl/timeline?r=full-utf-for-87|full-utf-for-87] branch?
      
      At least all the "string length" for 'yellow' and 'green' gives 1 as expected, not 2 as currently in Tcl 8.6 and 8.7
      
    2. login: "jan.nijtmans"
    3. mimetype: "text/x-fossil-wiki"
  6. Ticket change [ae016fbe2e] (rid 200866) by jan.nijtmans on 2022-05-17 19:46:05:

    1. closedate changed to: "2459717.32367083"
    2. closer changed to: "jan.nijtmans"
    3. icomment: "Since TIP #622 is merged to Tcl 8.7 now, closing."
    4. login: "jan.nijtmans"
    5. mimetype: "text/x-fossil-wiki"
    6. resolution changed to: "Fixed"
    7. status changed to: "Closed"