wxExecute: Unicode arguments on Linux, how to? Topic is solved

Do you have a typical platform dependent issue you're battling with ? Ask it here. Make sure you mention your platform, compiler, and wxWidgets version.
Post Reply
DenDev
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 223
Joined: Mon Jan 19, 2015 1:45 pm

wxExecute: Unicode arguments on Linux, how to?

Post by DenDev » Fri Mar 17, 2017 3:25 pm

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.
I have a bad habbit of not testing the code I post :D

coderrc
Earned some good credits
Earned some good credits
Posts: 141
Joined: Tue Nov 01, 2016 2:46 pm

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

Post by coderrc » Fri Mar 17, 2017 3:49 pm

have you tried using the %S or %ls format specifiers?

DenDev
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 223
Joined: Mon Jan 19, 2015 1:45 pm

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

Post by DenDev » Fri Mar 17, 2017 4:30 pm

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
I have a bad habbit of not testing the code I post :D

User avatar
doublemax
Moderator
Moderator
Posts: 13986
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

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

Post by doublemax » Fri Mar 17, 2017 5:42 pm

AFAIK Linux uses UTF-8 on the command line. Trace into the wxExecute call and see what it does.
Use the source, Luke!

DenDev
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 223
Joined: Mon Jan 19, 2015 1:45 pm

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

Post by DenDev » Fri Mar 17, 2017 6:33 pm

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.
I have a bad habbit of not testing the code I post :D

User avatar
doublemax
Moderator
Moderator
Posts: 13986
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

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

Post by doublemax » Fri Mar 17, 2017 6:46 pm

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?
Use the source, Luke!

DenDev
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 223
Joined: Mon Jan 19, 2015 1:45 pm

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

Post by DenDev » Sat Mar 18, 2017 12:11 pm

I have tried to upgrade wx to 3.1.0 and it seems to have solved the issue :)
I have a bad habbit of not testing the code I post :D

DenDev
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 223
Joined: Mon Jan 19, 2015 1:45 pm

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

Post by DenDev » Thu Mar 23, 2017 6:24 pm

I've had some more time to test this issue and wx version 3.1 has fixed the issue, marking as solved :)
I have a bad habbit of not testing the code I post :D

Post Reply