Restore wxConvAuto in wxTextInputStream used by wxExecute()

This reverts commit a05ae051d8 and allows
to correctly decode UTF-8 output of child processes again.

Also add a (disabled by default) test allowing to verify that this does
work now.

Closes #14720, #18382.
This commit is contained in:
Vadim Zeitlin
2019-04-21 20:09:13 +02:00
parent 731b3a804f
commit 7d3687f515
2 changed files with 26 additions and 8 deletions

View File

@@ -516,3 +516,28 @@ void ExecTestCase::TestOverlappedSyncExecute()
CPPUNIT_ASSERT_EQUAL( SLEEP_END_STRING, longSleepOutput.Last() );
#endif // !__WINDOWS__
}
#ifdef __UNIX__
// This test is disabled by default because it must be run in French locale,
// i.e. with explicit LC_ALL=fr_FR.UTF-8 and only works with GNU ls, which
// produces the expected output.
TEST_CASE("wxExecute::RedirectUTF8", "[exec][unicode][.]")
{
wxArrayString output;
REQUIRE( wxExecute("/bin/ls --version", output) == 0 );
for ( size_t n = 0; n < output.size(); ++n )
{
// It seems unlikely that this part of the output will change for GNU
// ls, so check for its presence as a sign that the program output was
// decoded correctly.
if ( output[n].find(wxString::FromUTF8("vous \xc3\xaates libre")) != wxString::npos )
return;
}
INFO("output was:\n" << wxJoin(output, '\n'));
FAIL("Expected output fragment not found.");
}
#endif // __UNIX__