Re: [Dev-C++] Converting char* to wxString
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Stefan K. <Klu...@gm...> - 2007-08-10 07:10:24
|
Lloyd schrieb: > On Thu, 2007-08-09 at 10:03 -0700, Luis Bras wrote: > >> centerx=temp; >> > > I think here is the error. centerx is a wxString and temp is char* and > they are incompatible data types. So if you want to assign temp to > centerx do the following > > > centerx=wxString::FromAscii(tempx); > > [static wxString FromAscii(const char* s)] > > Regards, > Lloyd > Hi, this only works if you are really using ASCII (no characters above 127) and no locale based conversion is applied. (see http://www.wxwidgets.org/manuals/stable/wx_wxstring.html#wxstringfromascii ) To do this assignment with locale based conversion use something like: centerx=wxString(tempx,wxConvCurrent); (see http://www.wxwidgets.org/manuals/stable/wx_mbconvclasses.html#wxmbconvobjects ) The question is, why aren't you staying in wxWidgets space and use wxTextFile instead of CTextFile. This way you wouldn't have to worry about string format conversions. Also be careful with the line cfile.InitializeWith((char *)file.mb_str( wxConvUTF8 )); Are you sure that every Operating System running your software saves its filenames in UTF8? Probably the conversion should be file.mb_str( wxConvFileName ); Regards, Stefan |