Good call DM!
Code: Select all
wxString doc = stream.GetString();
wxLogMessage ("%s", doc);
Works as expected, whilst ...
Code: Select all
wxString doc = stream.GetString();
wxLogMessage (doc);
... doesn't (asserts as described in OP).
It would have been interesting to see the content of a "bad" string.
With one of the working versions (std::cout or parameterised wxLogMessage), the string outputs exactly the same text as if you right click on the wxWidgets home page and select "View Page Source...".
I really wanted to debug which character was causing the problem but there doesn't seem to be a simple way to do this. I am not sure if it is because wxLogMessage uses macros or there are no debug symbols (I am pretty sure I built the debug version, but could try again).
There appear to be 16563 characters in the current version of the wxWidgets home page, but the wxString::size() reports 16547.
Anyway, I tried the following:
Code: Select all
for (size_t i = 7000; i < 8000; i++)
{
wxString slice = doc.Mid(i - 20, 20);
wxLogMessage (doc.Left(i));
}
Which asserts (repeatedly) when i == 7397, and the sliced string looks like this:
") but remains 100% c"
Another thing, if I make a string by pasting the complete page source as initialisation:
Code: Select all
wxString page_source = "<!DOCTYPE html><html><head><meta charset=\"utf-8\"><title>wxWidgets: Cross-Platform GUI ... "
(obviously truncated in the above sample) then it also works using both versions of wxLogMessage in the snippets above. So the cut / paste / escape quotes process also 'cleans' the string somehow.
wxWidgets 3.1.2, MinGW64 8.1.0, g++ 8.1.0, Ubuntu 19.04, Windows 10, CodeLite + wxCrafter
Some people, when confronted with a GUI problem, think "I know, I'll use Eclipse RCP". Now they have two problems.