Page 1 of 1

wxExecute: Unicode arguments on Linux, how to?

Posted: Fri Mar 17, 2017 3:25 pm
by DenDev
What must I do to be able to execute a program with a path containing unicode characters as argument?

The following will fail:

Code: Select all

wxString cmd = wxString::Format("\"%s\" \"%s\"", "/usr/bin/program", "/home/me/Skæg.ext");
wxExecute(cmd, wxEXEC_ASYNC | wxEXEC_MAKE_GROUP_LEADER, m_Process);
But if I rename the argument to "Skaeg.ext" and use that as argument there are no problems.

Re: wxExecute: Unicode arguments on Linux, how to?

Posted: Fri Mar 17, 2017 3:49 pm
by coderrc
have you tried using the %S or %ls format specifiers?

Re: wxExecute: Unicode arguments on Linux, how to?

Posted: Fri Mar 17, 2017 4:30 pm
by DenDev
The formatters are not part of the problem. This example does not work on Linux (works fine on Windows, though):

Code: Select all

wxString cmd = "/usr/bin/program";
cmd += " \"/home/me/Skæg.ext\"";
wxExecute(cmd, wxEXEC_ASYNC | wxEXEC_MAKE_GROUP_LEADER, m_Process);
P.S: Executing the command in a terminal (on Linux) works fine.

P.P.S: Same problem: viewtopic.php?t=39429

Re: wxExecute: Unicode arguments on Linux, how to?

Posted: Fri Mar 17, 2017 5:42 pm
by doublemax
AFAIK Linux uses UTF-8 on the command line. Trace into the wxExecute call and see what it does.

Re: wxExecute: Unicode arguments on Linux, how to?

Posted: Fri Mar 17, 2017 6:33 pm
by DenDev
doublemax wrote:AFAIK Linux uses UTF-8 on the command line. Trace into the wxExecute call and see what it does.
https://github.com/wxWidgets/wxWidgets/ ... x.cpp#L562

It converts the command line into char** and executes the command using "execvp": https://linux.die.net/man/3/execvp I cannot spot the issue, though. The program returns error "file not found", so I assume it is a bug in wxWidgets 3.0.2.

Re: wxExecute: Unicode arguments on Linux, how to?

Posted: Fri Mar 17, 2017 6:46 pm
by doublemax
The code you posted is from the latest master which is significantly different from the one in 3.0.2.

So which wxWidgets version are you using? And if you're using 3.0.2, can you try again with the latest development version?

Re: wxExecute: Unicode arguments on Linux, how to?

Posted: Sat Mar 18, 2017 12:11 pm
by DenDev
I have tried to upgrade wx to 3.1.0 and it seems to have solved the issue :)

Re: wxExecute: Unicode arguments on Linux, how to?

Posted: Thu Mar 23, 2017 6:24 pm
by DenDev
I've had some more time to test this issue and wx version 3.1 has fixed the issue, marking as solved :)