Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: a90b13432a8ba8dc017b9b75e96d1b86c095dc6ca65f87573e61ef461b3581a7
Ticket: 8a13caa31dd8e3a546b8d44c235bb98cd52bd774
Setting of system encoding isn't applied to stdout on certain circumstances
User & Date: sebres on 2025-08-16 23:02:32
Changes

  1. assignee changed to: "nobody"
  2. closer changed to: "nobody"
  3. cmimetype changed to: "text/x-fossil-wiki"
  4. comment changed to:
    I like it when an experimental branch brings to light problems that essentially have nothing to do with the experiment itself.
    
    My lazy branch (commit [6a997a7f19eaa6fa]) I provided for [effa2e2346f8372a] shows following error in encoding.test now:
    <code><pre style="margin-left:5pt">
    ==== encoding-24.3 EscapeFreeProc on open channels FAILED
    ==== Contents of test case:
    
    # Bug #219314 - if we don't free escape encodings correctly on channel
    # closure, we go boom
    set file [makeFile {
      encoding system iso2022-jp
      set a "乎乞也"; # 3 Japanese Kanji letters
      puts $a
    } iso2022.tcl]
    
    set f [open "|[list [interpreter] $file]"]
    fconfigure $f -encoding iso2022-jp
    set count [gets $f line]
    close $f
    removeFile iso2022.tcl
    list $count $line
    
    ---- Result was:
    9 \x00\x00\x00\x00\x00\x00\x00\x00\x00
    ---- Result should have been (exact matching):
    3 \u4E4E\u4E5E\u4E5F
    ==== encoding-24.3 FAILED
    </pre></code>
    (this is even valid for single test too, e. g. with <code>-file encoding.test -match encoding-24.3 -singleproc 1</code>)
    
    This particularly means that <code>[encoding system iso2022-jp]</code> doesn't change the encoding of stdout (it remains utf-8 in child process, so the parent reads a "noise").<br/>
    
    Changing of stdout encoding directly like here "fixes" the test:
    <code><pre style="margin-left:5pt">
    - encoding system iso2022-jp
    + fconfigure stdout -encoding iso2022-jp
    </pre></code>
    
    Also it is not clear why before the commit [6a997a7f19eaa6fa] it works as expected.<br/>
    As if moving of some inits (like Tcl_PkgProvideEx) has reached a "critical mass"...
    Or as something in package mechanisms touched encoding somewhere in different way and it appears now.
    
    Since it looks like an ugly Heisenbug and it is encoding issue (again), I think it were good to document this strange behavior.
    
  5. foundin changed to: "9.0"
  6. is_private changed to: "0"
  7. login: "sebres"
  8. priority changed to: "5 Medium"
  9. private_contact changed to: "50e9528765c18296566374b3fde2df942c394efd"
  10. resolution changed to: "None"
  11. severity changed to: "Severe"
  12. status changed to: "Open"
  13. submitter changed to: "sebres"
  14. subsystem changed to: "20. [interp]"
  15. title changed to:
    Setting of system encoding isn't applied to stdout on certain circumstances
    
  16. type changed to: "Bug"