Overview
| Artifact ID: | 28f90391d51376e49b02252c4b8ecc967a85abda05b4e4dad1c285a0c6a2a693 |
|---|---|
| Ticket: | 2bcf781c6c42f23a493a63f3b9fa723ceb184408
Incorrect size computed for some multi-byte UTF-8 characters |
| User & Date: | griffin on 2022-02-24 17:21:33 |
Changes
- assignee changed to: "nobody"
- closer changed to: "nobody"
- cmimetype changed to: "text/plain"
- comment changed 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] } - foundin changed to: "core-8-branch"
- is_private changed to: "0"
- login: "griffin"
- priority changed to: "5 Medium"
- private_contact changed to: "21780c4e03cc5884af69addd6efc1b71c50d9818"
- resolution changed to: "None"
- severity changed to: "Severe"
- status changed to: "Open"
- submitter changed to: "griffin"
- subsystem changed to: "44. UTF-8 Strings"
- title changed to:
Incorrect size computed for some multi-byte UTF-8 characters
- type changed to: "Bug"