Sign in to follow this  
Followers 0
autoITnewbie

Unicode passed in commandline

9 posts in this topic

#1 ·  Posted (edited)

Hi, I need help. I tried to read some chinese character being passed thru command line but it doesn't seem to work.

script example:

If $CmdLine[0] = 0 Then Exit(1)

$CmdVars = $cmdline

for $x = 1 to $cmdline[0]

msgbox (0,'','command line: '&$x&' - '&$cmdline[$x])

Next

Exit

running script:

c:\temp\runUnicodeCmd.exe Trong tnh yu c?a h?n d?i

Edited by autoITnewbie

Share this post


Link to post
Share on other sites



As far as I know, Windows doesn't support unicode command lines.

Share this post


Link to post
Share on other sites

It may depend on the page set for the cmd prompt to the language. But I know that others have made unicode cmd scripts by using edit.com and save the script which creates a script with some strange characters representing the unicode that works as needed.

:)

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Depends on how you are passing command line.

"Command Prompt" console window does not support Unicode.

Windows support Unicode, and command line with Unicode chars get passed to the app just fine. Then it's just a question of whether the app supports Unicode.

However, displaying Chinese requires additional files. Control Panel > Regional and Language Options > Languages > Install files for East Asian languages. (That's for WinXP at least, for other OSes the steps may be different).

Edited by Siao

"be smart, drink your wine"

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Thanks everyone, I was able to collect the unicode passed from commandline using our inhouse tool into an ini file saved as Encoding of UTF-8 but now I have a problem another problem when I try to read it back or try to get certain value from that ini file. it does not show the characters.

I tried to convert the ini file from unicode to ansi file using dos command "type" but when reading it, it does not show the correct characters =(

I'm not sure if iniread does not support unicode or is it msgbox does not display unicode?

Any thoughts?

Depends on how you are passing command line.

"Command Prompt" console window does not support Unicode.

Windows support Unicode, and command line with Unicode chars get passed to the app just fine. Then it's just a question of whether the app supports Unicode.

However, displaying Chinese requires additional files. Control Panel > Regional and Language Options > Languages > Install files for East Asian languages. (That's for WinXP at least, for other OSes the steps may be different).

Edited by autoITnewbie

Share this post


Link to post
Share on other sites

I'm not sure if iniread does not support unicode or is it msgbox does not display unicode?

Any thoughts?

Msgbox does not support unicode AFAIK. Others have read UTF-8 files so I would keep trying. Try your example and replace the msgbox with FileOpen/FileWrite/FileClose in unicode mode to see the result. Hopefully, someone with some chinese language experience may come to help you soon.

Share this post


Link to post
Share on other sites

Unicode version of AutoIt uses unicode versions of API functions (such as MessageBoxW instead of MessageBox), so that's NOT the problem.

Converting unicode to ansi, reading the result and then expecting to see unicode correctly is a weird idea too.

Instead of speaking in general terms, better try to post the code of what and how you are trying and failing to do, so we can get better idea.

For example the following script for me displays chinese correctly.

If $CmdLine[0] Then ;;display commandline arguments
    $str = ""
    For $i = 1 To $CmdLine[0]
        $str &= $i & ": " & $CmdLine[$i] & @CRLF
    Next
    MsgBox(0, "Command line", $str)
Else ;;self execute with some commandline argument
    ShellExecute(@AutoItExe, '"' & @ScriptFullPath & '" 知识')
EndIf

Posted Image


"be smart, drink your wine"

Share this post


Link to post
Share on other sites

I don't know what happened but I tried your script and here is what I got

Posted Image

result

Posted Image

Unicode version of AutoIt uses unicode versions of API functions (such as MessageBoxW instead of MessageBox), so that's NOT the problem.

Converting unicode to ansi, reading the result and then expecting to see unicode correctly is a weird idea too.

Instead of speaking in general terms, better try to post the code of what and how you are trying and failing to do, so we can get better idea.

For example the following script for me displays chinese correctly.

If $CmdLine[0] Then ;;display commandline arguments
    $str = ""
    For $i = 1 To $CmdLine[0]
        $str &= $i & ": " & $CmdLine[$i] & @CRLF
    Next
    MsgBox(0, "Command line", $str)
Else ;;self execute with some commandline argument
    ShellExecute(@AutoItExe, '"' & @ScriptFullPath & '" 知识')
EndIf

Posted Image

Share this post


Link to post
Share on other sites

That means the run box doesn't support unicode.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0