Menu

How to handle Cyrillic command line args?

Help
2017-01-29
2020-09-26
  • Sergey Karpushin

    Hi!

    I'm trying to use launch4j to wrap my uber-jar. All in all it does it's job BUT it converts any cyrillic symbols in command line args to question marks when forwarding to jar. How to fix that?

    1- When program is launched through launch4j-generated exe:
    a) args received in main() routine (notice this additional backslash "\")
    C:\temp\????????\\file.txt.pgp
    b) args discovered through WinAPI
    C:\temp\????????\file.txt.pgp

    2- When launch from command line using: java -jar pgpvaultgui-0.1.0.0.jar " C:\temp\Проверка\file.txt.pgp"
    a) args received in main() routine (that additional backslash is stil lthere, looks like java bug)
    C:\temp\????????\\file.txt.pgp
    b) args discovered through WinAPI
    C:\temp\Проверка\file.txt.pgp

    So it looks like encoding was lost between launch4j and java. Is it possible to configure it to work?

    Couple links in case you want to look what exactly I do in the code:
    - launch4j config currently used: https://github.com/skarpushin/pgpvault/blob/feature/pgpv-21/pgpvault-gui/launch4j.xml
    - JNA way to get windows command line: https://github.com/skarpushin/pgpvault/blob/feature/pgpv-21/pgpvault-gui/src/main/java/org/pgpvault/gui/tools/osnative/OsNativeWindowsImpl.java#L53
    - launch4j is used to wrap jar file as a part of maven build process: https://github.com/skarpushin/pgpvault/blob/feature/pgpv-21/pgpvault-gui/pom.xml#L201

    p.s. changing Windows default codepage could be a temporary workaround, but not a solution. Other programs can handle cyrillic characeters without this change.

    Any help is greately appreciated!
    Thank you, Sergey

     

    Last edit: Sergey Karpushin 2017-01-29
  • Sergey Karpushin

    Guys, any ideas?

     
  • Grzegorz Kowal

    Grzegorz Kowal - 2017-02-01

    Hi,

    It seems there is no immediate solution, I think launch4j would have to use the unicode function CreateProcessW instead of CreateProcess to handle this. I will add a feature request for this.

    Best regards,
    Grzegorz

     
  • MuldeR

    MuldeR - 2020-09-26

    Sorry, I know it's an old issue.

    But I came across the same problem and decided to write an alternative with full Unicode support:
    https://github.com/lordmulder/Launch5j

    Regards.

     

Log in to post a comment.