Jump to content

CmdLine parameter charset


Recommended Posts

Hi Experts,

I have script for get parameter as text with special charsets but i do not show as original line. How i can show as original? On this forum i find only How file open as UTF-8, etc. But this problem no.
cmd script:

@echo off
Test.exe "D:\Folder1\Folder2\ěščřžýáíéúů\Folder3" "green.txt"
exit

Test.au3 script:

#include <MsgBoxConstants.au3>
#include <file.au3>
#include <Array.au3>

Global $parameter
If Not $CmdLine[0] Then
    MsgBox(0, 'Info', 'Sorry but you not defined param for running.' & @CRLF & @CRLF & @CRLF & 'Examples:' & @CRLF & @CRLF & @ScriptName & ' "C:\Path\PathNext" "filename.ext"')
    Exit
EndIf

Global Enum $giParam_1,$giParam_2,$giParam_UBound
Global $aParams[$giParam_UBound]
For $i = 1 to UBound($CmdLine)-1
    If $i > $giParam_UBound Then
        MsgBox(0, 'Info', "More Params included than expected!" & @CRLF & @CRLF & " Accept Params is: " & $giParam_UBound)
        ;ExitLoop
        Exit
    EndIf
    $aParams[$i-1]=$CmdLine[$i]
Next

MsgBox(1, "Split", $aParams[$giParam_1] & "\" & $aParams[$giParam_2])
;MsgBox(1, "Split 2", $CmdLineRaw) ;;; have bug too

Exit

 

Bad output:

Image.png

 

Thanks in advance Experts.

Edited by truefriend-cz
Add Image
Link to comment
Share on other sites

  • Developers

I see you created a bug report, but for me all is working fine. I did the following:

  • Copied your script into test.au3 encoded UTF8 without BOM.
  • Compiled it
  • Started a CMD session and used your command line: Test.exe "D:\Folder1\Folder2\ěščřžýáíéúů\Folder3" "green.txt"

Knipsel.PNG

 

edit: also created your batch file and then it is going wrong so it is related to shelling the script from the batch file and not AutoIt3 itself.
Maybe other have an idea why this happens.

Jos

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Try adding this to the batch file at the start of it.

chcp 1252

So your batch file will look like this.

@echo off
chcp 1252
Test.exe "D:\Folder1\Folder2\ěščřžýáíéúů\Folder3" "green.txt"
exit

 

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

  • Developers
50 minutes ago, BrewManNH said:

So your batch file will look like this.

@echo off
chcp 1252
Test.exe "D:\Folder1\Folder2\ěščřžýáíéúů\Folder3" "green.txt"
exit

 

I've tried that option but had to do this to get it to display the correct characters:

MsgBox(1, "Split", BinaryToString(StringToBinary($aParams[$giParam_1] , 1), 4)& "\" & $aParams[$giParam_2])

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Odd, it worked fine for me.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...