doc that [socket] uses system encoding by default
Closed / Fixed630621ffffffffffffffffffffffffffffffffffCreated 24 years agoUpdated 24 years ago
Descriptionplain2002-10-29 18:07:13
Here is an excerpt from the Tcl'ers chat where
this was asserted to be a bug:
max: [...] imagine sockets between programs running
under different
locales. They will get wrong results unless using
-encoding utf-8
kennykb: Is that the case? I thought that only file
channels (and
standard I/O) defaulted to the system encoding.
rmax: tclsh8.4 [/tmp/tux]socket www.suse.de 80
sock3
tclsh8.4 [/tmp/tux]fconfigure sock3 -encoding
iso8859-15
kennykb: Urk, Reinhard is right. I'm not convinced
that's a feature
rather than a bug.
rmax: So what should be the default encoding for
sockets? binary?
aku: Just tried here, on windows. I get cp1252 as
encoding. That is
dreadful. I also believe it a bug. But what is a better
default ?
aku:Maybe binary ?
aku:crossed
kennykb: Hmmm, either binary or UTF-8.
[...]
NEM: Re default encoding for sockets - UTF-8 would be
good, as people
who want binary fconfigure binary now anyway
aku: nem - true
aku: default utf-8 would not impede http header
decoding, it is
constructed to have ASCII in it.
dkfplain2002-10-30 18:45:49
Logged In: YES user_id=79902 A well-designed protocol will specify what encoding(s) to use and how to detect them; leaving it up to chance is a bad move, even if it happens to work for the test cases you're using. For example, I think HTTP is actually defined to use either ASCII or ISO8859-1 for its headers (I forget which; I know bodies are 8859-1 by default) and provides an escaping mechanism for using other encodings (this is probably all based on MIME message headers.) Given this, the fact that Tcl's default socket encoding is system-specific is no great fault, since that's one of the things you should nail down by hand. IMO, this is not a bug at all, or at least not in Tcl...
davygrvyplain2002-11-28 06:17:55
Logged In: YES user_id=7549 This is interesting... What if we defaulted to ISO8859-1 all around knowing that someone will fconfigure -encoding ... it later. Would an all platform setting of ISO8859-1 for a default be bad?
hobbsplain2002-11-28 06:22:36
Logged In: YES user_id=72656 I would be strongly against such a potentially bug-introducing change. If anything, we should just reinforce more in the docs the known behavior that Tcl channels default to the system encoding, and leave it at that.
dkfplain2002-11-28 22:09:29
Logged In: YES user_id=79902 For my money, we should just reemphasize the point in socket.n that sockets use the system encoding by default, and that anyone interacting with another machine over the internet will (probably) need to negotiate/set the encoding.
hobbs Ticket [630621ffff]: 2 changes
[History diff]2002-12-01 04:05:19
dgp Ticket [630621ffff]: 1 change
[History diff]2003-04-14 11:14:29
dkf Ticket [630621ffff]: 2 changes
[History diff]2003-04-14 17:07:45
dkfplain2003-04-17 06:09:19
Logged In: YES user_id=79902 Fixed (as documentation update) in HEAD and 8.4
Log in (anonymous is fine) to add a comment.