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:
@@ -613,14 +613,7 @@ static bool ReadAll(wxInputStream *is, wxArrayString& output)
|
|||||||
// the stream could be already at EOF or in wxSTREAM_BROKEN_PIPE state
|
// the stream could be already at EOF or in wxSTREAM_BROKEN_PIPE state
|
||||||
is->Reset();
|
is->Reset();
|
||||||
|
|
||||||
// Notice that wxTextInputStream doesn't work correctly with wxConvAuto
|
wxTextInputStream tis(*is);
|
||||||
// currently, see #14720, so use the current locale conversion explicitly
|
|
||||||
// under assumption that any external program should be using it too.
|
|
||||||
wxTextInputStream tis(*is, " \t"
|
|
||||||
#if wxUSE_UNICODE
|
|
||||||
, wxConvLibc
|
|
||||||
#endif
|
|
||||||
);
|
|
||||||
|
|
||||||
for ( ;; )
|
for ( ;; )
|
||||||
{
|
{
|
||||||
|
@@ -516,3 +516,28 @@ void ExecTestCase::TestOverlappedSyncExecute()
|
|||||||
CPPUNIT_ASSERT_EQUAL( SLEEP_END_STRING, longSleepOutput.Last() );
|
CPPUNIT_ASSERT_EQUAL( SLEEP_END_STRING, longSleepOutput.Last() );
|
||||||
#endif // !__WINDOWS__
|
#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__
|
||||||
|
Reference in New Issue
Block a user