Convert wxString URL's to char*
Nusret Taşçı
nusi at sofha.de
Fri Apr 20 05:07:09 PDT 2007
A few questions which might help you understanding the errors:
Do you compile in ANSI or in Unicode Mode?
Which warnings/errors do you get, if you don't cast the return value of
ToAscii() and c_str() ... ?
Does ToAscii() (etc.) produce a temporary object and do you use a
pointer to a dead object in your call to printf()?
On 19.04.2007 16:02, Robbie Groenewoudt wrote:
> I'm trying to convert an URL to a char* but for some reason I'm getting
> not much...
>
> --- Code ---
> wxString wxStringUrl = wxT("http://dutchmega.nl/deimos/test/zooi
> <http://dutchmega.nl/deimos/test/zooi>");
> char* ansiURL = "http://dutchmega.nl/deimos/test/zooi";
>
> printf("ANSI URL: %s\n", ansiURL);
>
> // First method
> const char* test1 = (const char*)wxStringUrl.ToAscii();
> printf("URL1: %s\n", test1);
>
> // Second
> const char* test2 = (const char*)wxStringUrl.c_str();
> printf("URL2: %s\n", test2);
>
> // Third
> const char* test3 = (const char*)wxStringUrl.mb_str(wxConvUTF8);
> printf("URL3: %s\n", test3);
>
> // Fouth
> const char* test4 = (const char*)wxStringUrl.fn_str();
> printf("URL4: %s\n", test4);
>
> --- Output ---
> ANSI URL: http://dutchmega.nl/deimos/test/zooi
> URL1:
> URL2: h
> URL3:
>
> It's kinda weird...
More information about the wx-users
mailing list