I cam across strange problem on Windows 7. (American English locale).
In my application I use few calls to the Windows programs in the form: ExternalProcess defaultClass cshOne: 'some command'. In case of the "netstat" the result looks like: ExternalProcess defaultClass cshOne: 'netstat -n' '捁楴敶䌠湯敮瑣潩獮...." ExternalProcess defaultClass cshOne: 'ipConfig /all' - produces an error 'Strings only store Characters'. ExternalProcess defaultClass cshOne: 'dir' - produces directory listing as expected. After looking inside the WinProcess I noted that the encoding is being set UTF16. in the method: executeSingleCommand: aString "Execute a command and then shut down the process." "Always force unicode encoding to the shell so we know how to interpret any string results properly." self encoding: #'UTF-16'..... If I change the encoding in this method to UTF-8 everything looks good. There are few questions questions here: 1. Should I implement new method like: "executeSingleCommand: aString withEncoding:anEncoding" and use it instead? 2. Change the method to use UTF 8 - what kind of side effects can I see in this case on non English installations ? _______________________________________________ vwnc mailing list [hidden email] http://lists.cs.uiuc.edu/mailman/listinfo/vwnc |
See numerous previous discussions on this. You don't need to
implement such a method, you can just create a new instance of
ExternalProcess and set the encoding on it, and run the command. You
probably don't need to run it through a shell, you can just fork it. If
you change the encoding to UTF-8, the effect on non-English installs, or
anything that returns interesting characters on an English install will
be that the answer will be completely wrong. The encoding netstat is
using is probably, but not definitely, Microsoft code page 437 or 1252.
The /U shell argument tells programs to use UTF-16, which is what
Microsoft uses internally, but many programs won't pay attention to it.
But if you dont do that, then you can't even do a directory listing of
something that contains characters not in the 437 charset.
At 09:34 AM 2010-04-02, Mark Pirogovsky wrote: I cam across strange problem on Windows 7. (American English locale). In my application I use few calls to the Windows programs in the form: ExternalProcess defaultClass cshOne: 'some command'. In case of the "netstat" the result looks like: ExternalProcess defaultClass cshOne: 'netstat -n' 'à¨æ楴æ¶ä 湯æ®ç£æ½©ç®...." ExternalProcess defaultClass cshOne: 'ipConfig /all' - produces an error 'Strings only store Characters'. ExternalProcess defaultClass cshOne: 'dir' - produces directory listing as expected. After looking inside the WinProcess I noted that the encoding is being set UTF16. in the method: executeSingleCommand: aString "Execute a command and then shut down the process." "Always force unicode encoding to the shell so we know how to interpret any string results properly." self encoding: #'UTF-16'..... If I change the encoding in this method to UTF-8 everything looks good. There are few questions questions here: 1. Should I implement new method like: "executeSingleCommand: aString withEncoding:anEncoding" and use it instead? 2. Change the method to use UTF 8 - what kind of side effects can I see in this case on non English installations ? _______________________________________________ vwnc mailing list [hidden email] http://lists.cs.uiuc.edu/mailman/listinfo/vwnc --
Alan Knight [|], Engineering Manager, Cincom Smalltalk
_______________________________________________ vwnc mailing list [hidden email] http://lists.cs.uiuc.edu/mailman/listinfo/vwnc |
Free forum by Nabble | Edit this page |