Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 1ed05bb442f1512b7294fd1b78f4e50a1a94a9db616201848379216718a77306
Ticket: 6474fbd934378bb2a9d505f2799f9787a10a3f09
Tcl 8.7a5: why utf-8 is different?
User & Date: petasis on 2022-01-14 09:05:51
Changes

  1. assignee changed to: "nobody"
  2. closer changed to: "nobody"
  3. cmimetype changed to: "text/plain"
  4. comment changed to:
    Hi all,
    
    I observe a difference in converting strings to utf-8 between Tcl 8.6/8.7a1 and 8.7a5.
    
    In Tcl 8.6 I get:
    
    binary scan [encoding convertto utf-8 \uD800] H* hex; puts $hex
    > efbfbd
    
    which seems the correct utf-8 encoding.
    
    However, in Tcl 8.7a5 I get:
    
    binary scan [encoding convertto utf-8 \uD800] H* hex; puts $hex
    > eda080
    
    What is the reason for this difference? Shouldn't the utf-8 bytes be the same, no matter what internal representation for strings is used by Tcl?
    
    I know that this is invalid input (and only half of a "character"), but in my view what tcl 8.6 returns makes much more sense, as there is a (very) limited usage. The behaviour in 8.7 returns a character, hiding the problem in the input...
    
    George
    
  5. foundin changed to: "8.7a5"
  6. is_private changed to: "0"
  7. login: "petasis"
  8. priority changed to: "5 Medium"
  9. private_contact changed to: "3cb4dabca0e1e7b9d560b2ca060abb67f2a97f23"
  10. resolution changed to: "None"
  11. severity changed to: "Minor"
  12. status changed to: "Open"
  13. submitter changed to: "petasis"
  14. subsystem changed to: "44. UTF-8 Strings"
  15. title changed to: "Tcl 8.7a5: why utf-8 is different?"
  16. type changed to: "Bug"