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: 231
Joined: Mon Jan 19, 2015 1:45 pm

wxExecute: Unicode arguments on Linux, how to?

Post 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.
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 »

have you tried using the %S or %ls format specifiers?
DenDev
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 231
Joined: Mon Jan 19, 2015 1:45 pm

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

Post 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
I have a bad habbit of not testing the code I post :D
User avatar
doublemax
Moderator
Moderator
Posts: 19114
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

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

Post by doublemax »

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: 231
Joined: Mon Jan 19, 2015 1:45 pm

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

Post 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.
I have a bad habbit of not testing the code I post :D
User avatar
doublemax
Moderator
Moderator
Posts: 19114
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

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

Post 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?
Use the source, Luke!
DenDev
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 231
Joined: Mon Jan 19, 2015 1:45 pm

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

Post by DenDev »

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: 231
Joined: Mon Jan 19, 2015 1:45 pm

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

Post by DenDev »

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