How does one pass Unicode command line arguments to Tcl program (Windows 2000) 
Author Message
 How does one pass Unicode command line arguments to Tcl program (Windows 2000)

I'm spawning off a tcl shell from another tcl shell using exec and
passing it arguments with Unicode characters that are not in the
system code page. These appear garbled in the child process. Scanning
the code, it appears as though this is because tclsh uses a main() as
opposed to _wmain and hence the command line gets converted to the
system code page which does not contain all the chars in the argument.

Is this is a known issue ? Is there any way to pass Unicode arguments
to the child tcl shell through an exec command ?

Thanks in advance,

/Ashok



Mon, 01 Jan 2007 22:37:23 GMT  
 How does one pass Unicode command line arguments to Tcl program (Windows 2000)

Quote:

> I'm spawning off a tcl shell from another tcl shell using exec and
> passing it arguments with Unicode characters that are not in the
> system code page. These appear garbled in the child process. Scanning
> the code, it appears as though this is because tclsh uses a main() as
> opposed to _wmain and hence the command line gets converted to the
> system code page which does not contain all the chars in the argument.

> Is this is a known issue ?

I think its a known issue of the bizarre "system encoding" stuff on
windows and the tcl startup sequence. (at least it was discussed on the
tclers chat). But its not solved yet... maybe Don Porter will add his
comments to this.

Is there any way to pass Unicode arguments

Quote:
> to the child tcl shell through an exec command ?

One way would be to use open | to create a pipe, fconfigure it to utf-8
and do a puts to the pipe for communication, works, but its not what you
asked.

Michael



Mon, 01 Jan 2007 23:02:42 GMT  
 How does one pass Unicode command line arguments to Tcl program (Windows 2000)

Quote:

>> I'm spawning off a tcl shell from another tcl shell using exec and
>> passing it arguments with Unicode characters that are not in the
>> system code page. These appear garbled in the child process. Scanning
>> the code, it appears as though this is because tclsh uses a main() as
>> opposed to _wmain and hence the command line gets converted to the
>> system code page which does not contain all the chars in the argument.
>> Is this is a known issue ?

Yes.

Quote:

> I think its a known issue of the bizarre "system encoding" stuff on
> windows and the tcl startup sequence. (at least it was discussed on the
> tclers chat). But its not solved yet... maybe Don Porter will add his
> comments to this.

This is more about Windows than it is about Tcl.  Search the Bug
Tracker for "BuildCommandLine".

--
| Don Porter          Mathematical and Computational Sciences Division |

| http://math.nist.gov/~DPorter/                                  NIST |
|______________________________________________________________________|



Mon, 01 Jan 2007 23:30:56 GMT  
 How does one pass Unicode command line arguments to Tcl program (Windows 2000)

Quote:


>>> I'm spawning off a tcl shell from another tcl shell using exec and
>>> passing it arguments with Unicode characters that are not in the
>>> system code page. These appear garbled in the child process. Scanning
>>> the code, it appears as though this is because tclsh uses a main() as
>>> opposed to _wmain and hence the command line gets converted to the
>>> system code page which does not contain all the chars in the argument.

>>> Is this is a known issue ?

>Yes.


>> I think its a known issue of the bizarre "system encoding" stuff on
>> windows and the tcl startup sequence. (at least it was discussed on the
>> tclers chat). But its not solved yet... maybe Don Porter will add his
>> comments to this.

>This is more about Windows than it is about Tcl.  Search the Bug
>Tracker for "BuildCommandLine".

Incorrect.  The problem is Tcl_Main.  Tcl_Main expects the commandline to
be in the system code page even when a very acceptable unicode commandline
can be retrieved by GetCommandLineW (which is available on all Win32
flavors).  BuildCommandLine in win/tclWinPipe.c is creating the proper
unicode rep.

Until Tcl_Main is extended, no soup for us.
--

[species: human; planet: earth,milkyway(western spiral arm),alpha sector]



Tue, 02 Jan 2007 02:51:24 GMT  
 How does one pass Unicode command line arguments to Tcl program (Windows 2000)

Quote:



>>>> I'm spawning off a tcl shell from another tcl shell using exec and
>>>> passing it arguments with Unicode characters that are not in the
>>>> system code page. These appear garbled in the child process. Scanning
>>>> the code, it appears as though this is because tclsh uses a main() as
>>>> opposed to _wmain and hence the command line gets converted to the
>>>> system code page which does not contain all the chars in the argument.

>>>> Is this is a known issue ?

>>Yes.


>>> I think its a known issue of the bizarre "system encoding" stuff on
>>> windows and the tcl startup sequence. (at least it was discussed on the
>>> tclers chat). But its not solved yet... maybe Don Porter will add his
>>> comments to this.

>>This is more about Windows than it is about Tcl.  Search the Bug
>>Tracker for "BuildCommandLine".

>Incorrect.  The problem is Tcl_Main.  Tcl_Main expects the commandline to
>be in the system code page even when a very acceptable unicode commandline
>can be retrieved by GetCommandLineW (which is available on all Win32
>flavors).  BuildCommandLine in win/tclWinPipe.c is creating the proper
>unicode rep.

>Until Tcl_Main is extended, no soup for us.

It is not relevant that the app's startup is main rather than _wmain.  Two
reasons:

1) Using _wmain and #define'ing _UNICODE restricts the application to only
run on NT/2K/XP
2) we can ignore argv and get the unicode rep ourselves with
GetCommandLineW

The trouble is, once we have a clean unicode commandline, Tcl_Main wants
it dirty again.  Now if we could shuffle the API so that there is a new
utf-8 clean Tcl_MainUtf (pick a new name), Tcl_Main can just be wrapper
into it for the same behavior.  Once that's done the shells can be
modified.
--

[species: human; planet: earth,milkyway(western spiral arm),alpha sector]



Tue, 02 Jan 2007 03:03:11 GMT  
 How does one pass Unicode command line arguments to Tcl program (Windows 2000)

Quote:
>I'm spawning off a tcl shell from another tcl shell using exec and
>passing it arguments with Unicode characters that are not in the
>system code page. These appear garbled in the child process. Scanning
>the code, it appears as though this is because tclsh uses a main() as
>opposed to _wmain and hence the command line gets converted to the
>system code page which does not contain all the chars in the argument.

>Is this is a known issue ? Is there any way to pass Unicode arguments
>to the child tcl shell through an exec command ?

>Thanks in advance,

>/Ashok

https://sourceforge.net/tracker/?func=detail&aid=491789&group_id=1089...
https://sourceforge.net/tracker/download.php?group_id=10894&atid=3608...

The patch is very lame, but note the use of GetCommandLineW in setargv()
that is then converted to utf-8.  The trouble is...  Tcl_Main doesn't
accept a clean vector of args and there just isn't (yet) a way around it.
--

[species: human; planet: earth,milkyway(western spiral arm),alpha sector]



Tue, 02 Jan 2007 03:29:18 GMT  
 How does one pass Unicode command line arguments to Tcl program (Windows 2000)
For anyone else who runs into this issue, I added two commands to the TWAPI
extension to retrieve the Unicode command line on Windows (checked into
CVS, will be in the next release)

/Ashok



Sun, 07 Jan 2007 00:23:14 GMT  
 
 [ 8 post ] 

 Relevant Pages 

1. Piping data into Python on the command line - Windows 2000

2. pass more than one argument to source command

3. Q: pass more than one argument to source command

4. how to pass command line argument

5. how does one reference command line arguments??

6. How can I pass arguments from command line ?

7. Passing command line arguments

8. Howto pass command line arguments

9. Passing Command Line Arguments

10. Passing command line arguments

11. is tcl programs running on windows 2000 professional and windows xp gives diff results

12. passing arguments to an application from the command-line

 

 
Powered by phpBB® Forum Software