Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2010-11-19
22:34 • Ticket [491789ffff] setargv() doesn't support a unicode cmdline status s... artifact: 4fb2347064 user: nijtmans
2010-11-05
05:24 • Closed ticket [491789ffff]. artifact: a059fa1681 user: nijtmans
2010-10-12
04:51 • Ticket [491789ffff]: 4 changes artifact: 28b63d7b22 user: nijtmans
2010-09-16
21:46 • Add attachment 491789.patch to ticket [491789ffff] artifact: ac087115fd user: nijtmans
21:46 • Ticket [491789ffff] setargv() doesn't support a unicode cmdline status s... artifact: d74f6ac955 user: nijtmans
21:43 • Ticket [491789ffff]: 6 changes artifact: 8911640634 user: nijtmans
2005-11-06
05:47 • Ticket [491789ffff]: 1 change artifact: 70b6932a29 user: davygrvy
2004-11-03
02:47 • Add attachment patch.txt to ticket [491789ffff] artifact: a55fb935da user: davygrvy
02:47 • Ticket [491789ffff] setargv() doesn't support a unicode cmdline status s... artifact: b3560d950c user: davygrvy
2004-01-29
07:46 • Ticket [491789ffff]: 1 change artifact: 30692b4547 user: davygrvy
2002-02-24
09:57 • Ticket [491789ffff]: 2 changes artifact: 7f9c0acd9c user: dgp
09:56 • Ticket [491789ffff]: 7 changes artifact: 83fb0924ec user: dgp
09:56 • Open ticket [491789ffff]. artifact: f3762a0c33 user: dgp
2002-02-23
15:00 • Closed ticket [491789ffff]. artifact: fcec0996dc user: davygrvy
2001-12-15
01:08 • Ticket [491789ffff]: 4 changes artifact: 7af2e86fac user: dgp
01:00 • Ticket [491789ffff]: 4 changes artifact: b1ba0f7dc1 user: davygrvy
00:09 • Ticket [491789ffff]: 4 changes artifact: 5ef6cd0569 user: dgp
2001-12-12
21:50 • Ticket [491789ffff]: 2 changes artifact: 9546089bf5 user: dgp
06:22 • Ticket [491789ffff]: 1 change artifact: e20f7d5171 user: davygrvy
05:37 • Ticket [491789ffff]: 4 changes artifact: f6f95a7eab user: davygrvy
2001-12-11
22:37 • New ticket [491789ffff]. artifact: 194a53fd22 user: davygrvy

setargv() doesn't support a unicode cmdline

Closed / Fixed491789ffffffffffffffffffffffffffffffffffCreated 25 years agoUpdated 16 years ago
Descriptionplain2001-12-11 22:37:34
It is possible to have tclsh on windows get the
unicode commandline instead of the ansi one.
GetCommandlineW() exists on all win platforms
including Win95/OSR2.

Do I change the meaning of argv going into Tcl_Main()
and now call it clean UTF-8 and change the docs or
make a new wrapper function (Umm, Tcl_MainEx?) that
knows a clean argv and have the old one call the new
one after just doing the conversions?
davygrvyplain2001-12-12 05:37:37
File Added - 14535: patch.txt
davygrvy Ticket [491789ffff]: 1 change [History diff]2001-12-12 06:22:25
dgp Ticket [491789ffff]: 2 changes [History diff]2001-12-12 21:50:22
dgpplain2001-12-15 00:09:33
Logged In: YES 
user_id=80530

Tcl_Main assumes the system encoding for its
argv[i] arguments.  I'd be reluctant to change
that.  Is it reasonable to have the Win setargv()
convert string to the system encoding before passing
to Tcl_Main, or is that operation lossy?
davygrvyplain2001-12-15 01:00:56
Logged In: YES 
user_id=7549

Yeah, that would lossy and the limit I'm trying to get 
around.  Without changing the meaning of Tcl_Main's argv[],
how could we add this change?  I honestly have no use for 
this change, but the possibility for getting the full 
spread in unicode is there.  I haven't tested 
GetCommandLineW() on Win95, but it's doc'd as working.  This
probably isn't worth the sweat as it's just tclsh.
dgpplain2001-12-15 01:08:22
Logged In: YES 
user_id=80530

Only (half-formed) thought I have is to encode the
argv strings in some non-lossy encoding, then
somehow trick Tcl_FindExecutable into thinking
that's the system encoding.  Then finally in the
appInitProc switching back to the real system encoding.
Pretty kludgy.
davygrvyplain2002-02-23 15:00:26
Logged In: YES 
user_id=7549

I don't see a way to impliment this without changing the 
Tcl_Main sig.  Not good.
dgp Open ticket [491789ffff]. [History diff]2002-02-24 09:56:15
dgpplain2002-02-24 09:56:16
Logged In: YES 
user_id=80530

Rather than close this completely, I'm moving it
to Feature Requests for further consideration
down the road.
dgp Ticket [491789ffff]: 2 changes [History diff]2002-02-24 09:57:53
davygrvy Ticket [491789ffff]: 1 change [History diff]2004-01-29 07:46:46
davygrvyplain2004-11-03 02:47:18
File Deleted - 14535: 



File Added - 107390: patch.txt

Logged In: YES 
user_id=7549

Here is a new patch that doesn't modify the signature of
Tcl_Main, but moves the body of Tcl_Main to a new
Tcl_UniMain with the sig of:
int Tcl_UniMain(int argc, Tcl_UniChar **wargv,
Tcl_AppInitProc *appInitProc)

This change allows Tcl_Main to just 'upcast' it's argv
vector to unicode and call Tcl_UniMain and allows a user of
the API to call Tcl_UniMain directly.  This fixes the long
standing unicode commandline args problem.

Sticky points are:
1) We need a new unicode form of Tcl_FindExecutable
2) maybe the choice of name is better Tcl_WMain and we
should use the wchar_t type instead to match the declaration
of microsoft's use of _wmain (not an ANSI feature)?
davygrvy Ticket [491789ffff]: 1 change [History diff]2005-11-06 05:47:41
nijtmansplain2010-09-16 21:43:07
Here is a first patch, implementing part of what is suggested here.

It adds a new function Tk_MainExW, which does the
same as Tk_MainEx, but then using wchar_t in stead
of char arguments.

winMain.c is not modified yet, but I already hacked
a modified winMain which uses this Tk_MainExW,
so I know it works. A clean new winMain.c
implementation is the next step
nijtmansplain2010-09-16 21:46:09
File Added - 386839: 491789.patch
nijtmansplain2010-10-12 04:51:47
Now implemented in HEAD, for Tk on MSVC++.
nijtmansplain2010-11-05 05:24:10
allow_comments - 1

Implementation complete, for Tcl as well. In HEAD
nijtmansplain2010-11-19 22:34:18
Well, I thought the implementation was compete, because I
was satisfied with MSVC++ only. I assumed that for mingw32
and cygwin this would be impossible, because support for the
mWinMain/_wmain functions is not built in there.

However, I discovered the existance of mingw-w64, whose guys
implemented the -municode linker option, which does exactly
what was required. Therefore my follow-up commit
(HEAD 2010-11-17), which enhanced configure.in checking
if there is a workong -municode option. This makes the unicode
command line compiletely working with the latest mingw-w64

Then, noting that mingw32 and cygwin already have a
workaround, not thrusting their crt implementation, I
could use this trick for mingw32 and cygwin as well.
Why not use the normal WinMain/main entry point,
but throw away the command and just get it again
using GetCommandLineW. This way we still can
get the unicode commandline! That was my
next follow-up commit (2010-11-18).

So, now it's really complete!
Log in (anonymous is fine) to add a comment.

Attachments: