If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
-
extreme001
- I live to help wx-kind

- Posts: 192
- Joined: Fri Dec 22, 2006 9:17 am
- Location: Germany
-
Contact:
Post
by extreme001 » Wed Sep 19, 2012 8:17 pm
Hi!
I downloaded a file that contains %-Token in it's filename. While reading it line by line i get a general FORMAT-Issue. The file was renamed by the browser. Any idea on how to read it if there are %-Token in the filename that is pushed wxLog?
The errorline:
Code: Select all
wxLogMessage(wxString::Format(_T("Parse: %s"), filename));
Here's the screenshot:

- The error message
- file_error.JPG (28.58 KiB) Viewed 1739 times
How to resolve it?
Thank you very much!!!
-
doublemax
- Moderator

- Posts: 15828
- Joined: Fri Apr 21, 2006 8:03 pm
- Location: $FCE2
Post
by doublemax » Wed Sep 19, 2012 8:32 pm
wxLogXXX methods already are printf-like, so you don't need the wxString::Format. And in this case it's responsible for the problem, because the string gets parsed twice.
Code: Select all
wxLogMessage( _T("Parse: %s"), filename );
Use the source, Luke!
-
PB
- Part Of The Furniture

- Posts: 2922
- Joined: Sun Jan 03, 2010 5:45 pm
Post
by PB » Thu Sep 20, 2012 5:16 am
You still have to do something about "%" in the string, if it is not a printf format specifier. What I do is to send strings coming from a user / of unknown origin through a function that doubles the "%" before passing them to wxLog...(). Not a very good solution, I'd like to learn a better one myself.
-
Auria
- Site Admin

- Posts: 6695
- Joined: Thu Sep 28, 2006 12:23 am
-
Contact:
Post
by Auria » Thu Sep 20, 2012 4:27 pm
PB wrote:You still have to do something about "%" in the string, if it is not a printf format specifier. What I do is to send strings coming from a user / of unknown origin through a function that doubles the "%" before passing them to wxLog...(). Not a very good solution, I'd like to learn a better one myself.
doesn't wxLog("%s", your_string_with_stuff_in_it) just work for that??
"Keyboard not detected. Press F1 to continue"
-- Windows
-
PB
- Part Of The Furniture

- Posts: 2922
- Joined: Sun Jan 03, 2010 5:45 pm
Post
by PB » Thu Sep 20, 2012 6:22 pm
Auria wrote:doesn't wxLog("%s", your_string_with_stuff_in_it) just work for that??
Yes, of course it does. IIRC I had a situation in which this was not a good solution, but for the life of me I can't now remember why was that.

-
extreme001
- I live to help wx-kind

- Posts: 192
- Joined: Fri Dec 22, 2006 9:17 am
- Location: Germany
-
Contact:
Post
by extreme001 » Fri Sep 21, 2012 7:08 am
Yes...i hoped there would be a routine, a method or something which does it for me.
Thank you very much!