← Back to team overview

kicad-developers team mailing list archive

Re: Re: wxString.c_str()

 

emmedics4 wrote:
> --- In kicad-devel@xxxxxxxxxxxxxxx, Dick Hollenbeck <dick@...> wrote:
>> Jean-Pierre & Other Developers,
>> It is my understanding that on newer versions of wxWidgets, we will not 
>> be able to pass wxString.c_str() to the Printf() function of wxString. 
>> And wxString.GetData() will not exist.
>> So according to my understanding, we are better writing:
>>
>> wxString s;
>> wxString formatMe;
>>
>> s.Printf( wxT("%s"), GetChars( formatMe ) );
>> than this:
>> s.Printf( wxT("%s"), formatMe.c_str() );
>> For 2.9 or 3.0 the c_str() will not work, at least that is my 
>> understanding based on a snapshot 5 months ago when I wrote GetChars().
> 
> Just to focus better the situation there is an equivalence in wx2.9 for c_str() and is GetData().
> Different will be the situation for the charset as wx3.0 will manage only UNICODE strings.

Has anyone tried using the (const wxChar *) cast operator? I've been
using it in Printf and the logging function calls and it appears to work
fine. It is just a typedef for wxString::const_pointer but it returns
the correct character type depending on the character set used in
wxWidgets. I like it because it is reasonably descriptive and it
appears to work with most versions of wxWidgets. Using the example
above, it is used as follows:

s.Printf( wxT( "%s" ), (const wxChar*) formatMe );

It also works with the gettext _() macro.

Wayne

> 
> --
> Marco

 




Follow ups

References