Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2006-03-29
05:40 • Closed ticket [1442305fff]: fconfigure stdout -encoding error plus 7 other c... artifact: a53dccde5a user: hobbs
2006-03-11
04:57 • Ticket [1442305fff]: 4 changes artifact: c2eef1e5bc user: davygrvy
2006-03-10
22:02 • Ticket [1442305fff]: 4 changes artifact: 74970cc0ef user: dgp
14:42 • Ticket [1442305fff]: 4 changes artifact: 55412c3bec user: davygrvy
11:48 • Ticket [1442305fff]: 4 changes artifact: 3e4c303ab5 user: dgp
2006-03-04
10:36 • Ticket [1442305fff]: 4 changes artifact: 3df76c59f4 user: davygrvy
02:17 • Ticket [1442305fff]: 4 changes artifact: 7457990075 user: davygrvy
00:50 • Ticket [1442305fff]: 6 changes artifact: 7a6e9bc768 user: hobbs
2006-03-03
22:04 • Ticket [1442305fff]: 4 changes artifact: f6b0a711a1 user: jcw
16:27 • Ticket [1442305fff]: 3 changes artifact: ae650ef165 user: dkf
08:10 • New ticket [1442305fff]. artifact: 76d03aba1c user: nobody

fconfigure stdout -encoding error

Closed / Duplicate1442305fffffffffffffffffffffffffffffffffCreated 21 years agoUpdated 21 years ago
Descriptionplain2006-03-03 08:10:26
With 8.4.12, I see the following error (W2k, WinXP):

 % info patchlevel
 8.4.12
 % fconfigure stdout -encoding cp437
 ?fconfigure stdout -encoding
 ???
dkf Ticket [1442305fff]: 3 changes [History diff]2006-03-03 16:27:59
jcwplain2006-03-03 22:04:28
Logged In: YES 
user_id=1983

Might be the same issue as reported here:
  http://www.equi4.com/cgi-bin/cvstrac/tclkit/tktview?tn=7
hobbsplain2006-03-04 00:50:19
Logged In: YES 
user_id=72656

I suspect this has to do with the changes from 8.4.11 to
8.4.12 that added Unicode console support on Windows NT. 
This screwed up Expect for Windows, but it turned out that
that just required adopting stacked channels' encodings.  Is
it possible that this has lost us the ability to modify the
std channel encoding?
davygrvyplain2006-03-04 02:17:32
Logged In: YES 
user_id=7549

<davygrvy> here's my thoughts..  (mostly off the cuff) As
the channel driver determines it's encoding based on the
system it is running under, allowing it to be changed is not
good.  It isn't good cause the channel driver code isn't
told about the change
<ijchain> <tclguy> ok, context is that the Windows unicode
console patch may be problematic (again)
<davygrvy> it'd be nice if channel drivers got encoding
change notices from the generic layer
<davygrvy> just the unicode ones, anyways
<davygrvy> so it can know WriteConsoleA or WriteConsoleW
<davygrvy> calling WriteConsoleW with non-unicode after
'fconfigure -encoding cp437' is the trap it falls into
<davygrvy> the channel driver didn't know about the switch
davygrvyplain2006-03-04 10:36:28
Logged In: YES 
user_id=7549

<tclguy@Jabber> we can keep the W perhaps, but we need a
conversion to desired encoding, no?

The problem as I see it is that we don't really know what
this buffer is that comes into the Tcl_DriverOutputProc.  We
could do an upconversion to unicode in the TDOP, but we'd
take a performance hit asking what our channels encoding is,
then perform the upcast.

This is what I don't understand..  Why do we (as a channel
driver) not tell the generic ourselves what we are?  I mean,
we know what the console's codepage is and how to change it
(G|S)etConsoleCP.

<pipedream>
What if an optional new entry into the driver structure for
version 5 existed so the generic layer can hook into us so
we can apply rules for encodings?  That'd be sweet..

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/intl/unicode_81rn.asp

Oh, you want EBCDIC?  SetConsoleCP(37); failed, so I'll
return TCL_ERROR so [fconfigure] barfs back.

Oh.. you want unicode, set flag so our TDOP will use
WriteConsoleW, return TCL_OK to allow [fconfigure] to change
the generic side.
</pipedream>

Would that work?  How much code change is that?
dgpplain2006-03-10 11:48:25
Logged In: YES 
user_id=80530


any resolution possible
for 8.4.13 / 8.5a4 ?
davygrvyplain2006-03-10 14:42:17
Logged In: YES 
user_id=7549

this is not an easy fix.  A temp fix might be to not let
[fconfigure -encoding] modify a console channel at all.

But to do that, we still need to add a new hook vector to
Tcl_ChannelType
dgpplain2006-03-10 22:02:39
Logged In: YES 
user_id=80530


ok, then, is the bug
severe enough that we
should consider reverting
the change that introduced it?
davygrvyplain2006-03-11 04:57:35
Logged In: YES 
user_id=7549

That's a tough question..  I do want to see the console
channel driver using unicode for WriteConsoleW() on the
systems that allow it.  This is a very good thing.

revert would be the safe descision for the moment until a
hook method is constructed to keep the driver in sync with
the generic layer.
hobbsplain2006-03-29 05:40:25
Logged In: YES 
user_id=72656

Dup of 1256872 patch.  Reverted for 8.4.13, but not 8.5 (yet).
Log in (anonymous is fine) to add a comment.