Re: [Dev-C++] Converting char* to wxString
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Luis B. <lf...@ya...> - 2007-08-10 12:08:24
|
=0AThanks for the links and for the help, and you are correct saying that = =0Aits best to use wxFile, but CTextFile is a class that I have created to= =0Abe able to read complex text files with a special format.=0A=0ABest rega= rds,=0A Luis=0A=0A----- Original Message ----=0AFrom: Stefan Klug <Klug.= St...@gm...>=0ATo: dev...@li...=0ASent: Friday, Au= gust 10, 2007 8:10:27 AM=0ASubject: Re: [Dev-C++] Converting char* to wxStr= ing=0A=0ALloyd schrieb:=0A> On Thu, 2007-08-09 at 10:03 -0700, Luis Bras wr= ote:=0A> =0A>> centerx=3Dtemp;=0A>> =0A>=0A> I think here is the erro= r. centerx is a wxString and temp is char* and=0A> they are incompatible da= ta types. So if you want to assign temp to=0A> centerx do the following=0A>= =0A>=0A> centerx=3DwxString::FromAscii(tempx);=0A>=0A> [static wxString Fro= mAscii(const char* s)]=0A>=0A> Regards,=0A> Lloyd=0A> =0AHi,=0A=0Athis = only works if you are really using ASCII (no characters above 127) =0Aand n= o locale based conversion is applied.=0A(see =0Ahttp://www.wxwidgets.org/ma= nuals/stable/wx_wxstring.html#wxstringfromascii )=0ATo do this assignment w= ith locale based conversion use something like:=0Acenterx=3DwxString(tempx,= wxConvCurrent);=0A(see =0Ahttp://www.wxwidgets.org/manuals/stable/wx_mbconv= classes.html#wxmbconvobjects =0A)=0AThe question is, why aren't you staying= in wxWidgets space and use =0AwxTextFile instead of CTextFile.=0AThis way = you wouldn't have to worry about string format conversions.=0A=0AAlso be ca= reful with the line=0Acfile.InitializeWith((char *)file.mb_str( wxConvUTF8 = ));=0AAre you sure that every Operating System running your software saves = its =0Afilenames in UTF8?=0AProbably the conversion should be file.mb_str( = wxConvFileName );=0A=0ARegards,=0AStefan=0A=0A=0A=0A=0A=0A=0A=0A=0A = =0A________________________________________________________________________= ____________=0AChoose the right car based on your needs. Check out Yahoo! = Autos new Car Finder tool.=0Ahttp://autos.yahoo.com/carfinder/ |