Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: afb3da897f09a1f24c57665429ff0a6edca17d7e9508e160be531e660b4587b7
Ticket: b3fbd9a6e028dfa5c0138a461fdb5b4ae09ffebc
string trim generates invalid utf-8 for some codepoints
User & Date: chelmuth on 2026-01-06 07:18:10
Changes

  1. assignee changed to: "nobody"
  2. closer changed to: "nobody"
  3. cmimetype changed to: "text/x-fossil-plain"
  4. comment changed to:
    The following code produces invalid UTF-8 strings and causes puts to abort.
    
    set padded_unicode_22c5 " \U22c5 "
    set trimmed_unicode_22c5 [string trim $padded_unicode_22c5]
    
    puts "padded_unicode_22c5: '$padded_unicode_22c5'"
    puts "trimmed_unicode_22c5: '$trimmed_unicode_22c5'"
    
    The same happens for U+2020.
    
    Most interestingly the characters are represented by UTF-8 sequences like follows.
    
    U+22C5 0xE2 0x87 0x85
    U+2020 0xE2 0x80 0xA0
    
    The first sequence contains 0x85 and the second 0x80.
    U+0085 (0xC2 0x85) is <Next Line> (NEL).
    U+0080 (0xC2 0x80) is <Padding Character> (PAD).
    Both should be trimmed I expect but are not in the string above (0xC2 is missing).
    
    I also tested Tcl 9.0.3, which works like a charm.
    
  5. foundin changed to: "8.6.17"
  6. is_private changed to: "0"
  7. login: "chelmuth"
  8. priority changed to: "5 Medium"
  9. private_contact changed to: "7313b123087982208eac04b14054e0c43344d79f"
  10. resolution changed to: "None"
  11. severity changed to: "Important"
  12. status changed to: "Open"
  13. submitter changed to: "chelmuth"
  14. subsystem changed to: "44. UTF-8 Strings"
  15. title changed to:
    string trim generates invalid utf-8 for some codepoints
    
  16. type changed to: "Bug"