Similar Threads:
1.Formatting double with wxString::Format
Hi,
my program is compiled with MinGW on XP with wxWidgets-2.8.8.
Using wxString::Format("<%010.2f>", 3.14) I get the result
"< 3.14>" (padded with blanks).
When I use sprintf(buf, "<%010.2f>", 3.14) instead, then I get the
correct result "<0000003.14>".
Is this a bug in wxString?
Lutz
2.wxString.Format()
3.[2.5.3] wxString::Format and unicode
Hi:
wxString::Format("Text: %s", bla)
doesn't work with an unicode build. It does not compile. I know this is
to be expected.
However, these alternatives also do not work:
wxString::Format(_("Text: %s"), bla)
wxString::Format(wxTRANSLATE("Text: %s"), bla)
wxString::Format(_T("Text: %s"), bla)
wxString::Format(wxT("Text: %s"), bla)
The program compiles, but then it hangs on that line. The only way I
found to make it work is to use:
_("Text: ") + wxString(bla, *wxConvCurrent)
I'm not claiming that this is an error. I actually think it is not. I
just want to suggest that the docs and the examples on
wxString::Format() should be updated. And perhaps a way should be found
to prevent the program to hang.
Also note that wxString::Format(_("Text: %d"), number) works fine.
Here is a code that illustrates what I'm saying. Uncomment the line
after
// this doesn't work
and the program hangs, although it compiles fine:
///////////////////////////////////////////
#include <wx/wx.h>
class MyApp: public wxApp {
virtual bool OnInit();
};
IMPLEMENT_APP(MyApp)
bool MyApp::OnInit() {
wxString msg = _("A number: ");
int number = 33;
// this works:
msg += wxString::Format(_("decimal: %d, "), number);
char *text = "33";
// this doesn't work:
// msg += wxString::Format(_("string: %s."), text);
// but this does:
msg += _("string: ") + wxString(text, *wxConvCurrent) + _(".");
wxMessageBox(msg, _("wxString::Format() with Unicode"), wxOK |
wxICON_ERROR);
return false;
}
/////////////////////////////////////
Just dump these lines into a file and compile.
Thanks
Paulo
---------------------------------------------------------------------
To unsubscribe, e-mail: XXXX@XXXXX.COM
For additional commands, e-mail: XXXX@XXXXX.COM
4.wxString, Format etc.
Hi folks,
what's the rationale behind wxString wrt. to converting to/from char *
etc.? Is there any at all? Why doesn't wxString::Format understand
wxStrings?
One of the things I want to do is use wxString::Format with wxStrings.
Seems this hasn't been anticipated. Now I've tried the various
conversion functions (c_str(), char_str(), fn_str(), mb_str(),
wchar_str(), wc_str(), To8BitData()) and only c_str() seems to work,
however, the documentation says that it'll no longer work with wxWidgets 3.
What am I supposed to use then? Another thing is pathnames; I'm using
char_str() since fn_str() (which, according to the documentation, is the
proper thing to use, doesn't work.)
What's the canonical way to get anything useful out of a wxString?
Portably and without having to write special code for each combination
of OS/char width?
I'm currently using wxGTK 2.8.7 / Unicode but it should work on all
platforms (I don't care for ANSI builds).
5.Re[2]: wxString, Format etc.
6. wxString::Format way of putting commas in numbers: ie 10,000
7. CVS HEAD wxString::Format crash
8. wxString::Format and Unicode