No data shown width printf and UniCode Topic is solved

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.
Post Reply
kea_
Experienced Solver
Experienced Solver
Posts: 59
Joined: Wed Oct 17, 2007 7:32 am

No data shown width printf and UniCode

Post by kea_ » Fri May 29, 2009 9:18 am

Hello together,
I have installed the wxWidget (UniCode) and Code::Blocks on my Ubuntu System.

So I've done a litle example just for a test.

Code: Select all

#include <iostream>
#include <wx/string.h>

using namespace std;

int main()
{
    wxString s = _T("Hello");
    char const *sOut = s.mb_str(wxConvUTF8);
    printf("%s", sOut);

    return 0;
}
The program runs but there is no output.

Has anybody an idea?

Thanks kea_

DavidHart
Site Admin
Site Admin
Posts: 3989
Joined: Thu Jan 12, 2006 6:23 pm
Location: IoW, UK

Post by DavidHart » Fri May 29, 2009 9:27 am

Hi,

To answer your specific question, you have the problem discussed in http://wiki.wxwidgets.org/WxString#Conv ... mal_String

A more general answer is to not use printf. There is a wxPrintf which copes with wxChar and wxChar*; or you can use e.g. wxLogDebug, to which you can pass s.c_str().

Regards,

David

kea_
Experienced Solver
Experienced Solver
Posts: 59
Joined: Wed Oct 17, 2007 7:32 am

Post by kea_ » Fri May 29, 2009 1:24 pm

Thank you for your answer.

I will read this site.

kea_

Post Reply