|
From: EricT <tw...@gm...> - 2025-11-02 09:25:28
|
Subject: Re: TIP 561 - Dynamic encoding fix and other updates
Ashok,
You're absolutely right - hardcoding UTF-8 was an oversight. Thank you for
catching that!
I've updated the transform to query the channel's encoding dynamically:
# Get the channel's actual encoding instead of hardcoding UTF-8
set enc [fconfigure $what -encoding]
if {$enc ne "binary"} {
set data [encoding convertfrom $enc $data]
}
I'm not entirely sure how to test different encodings in practice, but the
change didn't break anything and the logic is clearly more correct.
I've also made several other improvements based on testing:
1. Removed the pre-8.6 puts wrapper code entirely (targeted for Tcl 9.1+)
2. Fixed console show/hide cycling so the console can be closed and
reopened multiple times
3. The console command now properly manages channel transforms on hide/show
4. Changed window close from "destroy" to "wm withdraw" for reopening
capability
The updated code is at: https://github.com/rocketship88/tcl-console-unix
When convenient, it would be great to get this merged into the TIP 561
branch. I appreciate it being on Tuesday's agenda, though unfortunately I
won't be able to attend (4 AM my time, and no mic/camera). I may try to
lurk if I'm awake.
Thank you,
Eric
On Sun, Nov 2, 2025 at 1:07 AM apnmbx-public--- via Tcl-Core <
tcl...@li...> wrote:
> Eric,
>
>
>
> I believe (but not completely sure) that the bytes are not always UTF-8
> encoded but rather encoded as per the channel’s configuration. So decoding
> should probably be done using whatever encoding has been configured for the
> channel.
>
>
>
> /Ashok
>
>
>
> *From:* EricT <tw...@gm...>
> *Sent:* Saturday, November 1, 2025 3:14 AM
> *To:* Tcl...@li...
> *Subject:* [TCLCORE] TIP 561 - Working console.tcl implementation with
> channel transforms
>
>
>
> Hello Tcl Core Team,
>
> I've successfully resolved the Unicode handling issues with the channel
> transform
> implementation for TIP 561 (Console command for Linux/Unix).
>
> The key fix was recognizing that channel transforms receive UTF-8 encoded
> bytes,
> which need to be decoded back to Unicode strings before passing to the Tk
> console
> widget:
>
> set data [encoding convertfrom utf-8 $data]
>
> This eliminates the need for the pre-8.6 puts wrapper method, providing a
> clean,
> API-based solution using TIP#230 channel transforms.
>
> The working implementation is available at:
>
> https://github.com/rocketship88/tcl-console-unix
>
> Since I don't have permissions to update the TIP or its branch, could
> someone
> kindly review the code and update console.tcl in the TIP 561 repository if
> it
> looks acceptable?
>
> The implementation has been tested on Pop!_OS Linux with proper Unicode
> display,
> console cleanup, and output restoration to the terminal.
>
> Thank you,
> Eric
> _______________________________________________
> Tcl-Core mailing list
> Tcl...@li...
> https://lists.sourceforge.net/lists/listinfo/tcl-core
>
|