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.
nexes
In need of some credit
Posts: 9 Joined: Sat Feb 18, 2006 12:44 am
Post
by nexes » Sun Mar 05, 2006 5:28 am
Code: Select all
switch ( (const char) ((tempString.SubString(tempString.Length()-1, tempString.Length()-1)).mb_str(wxConvUTF8))[0] )
{
case 'h':
break;
}
Is there a cleaner way of converting a wxString into a char?
protocol
Moderator
Posts: 680 Joined: Wed Jan 18, 2006 6:13 pm
Location: Dallas, TX
Contact:
Post
by protocol » Sun Mar 05, 2006 8:27 am
I'm not really sure if your substring is doing anything special, because wxString implements the array operator.
Code: Select all
wxString str = "good";
wxChar c = str[1]; // returns 'o'
Review the wxString documentation here.
http://www.wxwidgets.org/manuals/2.6.2/wx_wxstring.html
Hope that helps. Let me know if you need any more examples.
nexes
In need of some credit
Posts: 9 Joined: Sat Feb 18, 2006 12:44 am
Post
by nexes » Sun Mar 05, 2006 5:02 pm
protocol wrote: I'm not really sure if your substring is doing anything special, because wxString implements the array operator.
Code: Select all
wxString str = "good";
wxChar c = str[1]; // returns 'o'
Review the wxString documentation here.
http://www.wxwidgets.org/manuals/2.6.2/wx_wxstring.html
Hope that helps. Let me know if you need any more examples.
Ahh, yes, the array operator. Hmm, that would make it partly cleaner.
Can you tell me if I can use a wxChar in a switch statement? Or do I have to cast it into the char like I have?
cecilio
I live to help wx-kind
Posts: 189 Joined: Fri Dec 03, 2004 8:44 am
Location: spain
Contact:
Post
by cecilio » Sun Mar 05, 2006 7:04 pm
Yes, you can use an wxChar in a switch statement. For example:
wxChar cStep = sStep.GetChar(0);
switch (cStep) {
case L'c':
leio
Can't get richer than this
Posts: 802 Joined: Mon Dec 27, 2004 10:46 am
Location: Estonia, Tallinn
Contact:
Post
by leio » Sun Mar 05, 2006 7:16 pm
No particular need to break non-unicode builds by using always a wchar_t there, unconditionally disregarding wxwidgets build type.
Compilers: gcc-3.3.6, gcc-3.4.5, gcc-4.0.2, gcc-4.1.0 and MSVC6
OS's: Gentoo Linux, WinXP; WX: CVS HEAD
Project Manager of wxMUD -
http://wxmud.sf.net/
Developer of wxGTK;
gtk+ port maintainer of OMGUI -
http://www.omgui.org/
cecilio
I live to help wx-kind
Posts: 189 Joined: Fri Dec 03, 2004 8:44 am
Location: spain
Contact:
Post
by cecilio » Sun Mar 05, 2006 8:37 pm
No particular need to break non-unicode builds by using always a wchar_t there, unconditionally disregarding wxwidgets build type.
You are right. Use wxT('x') instead of L'x'. Sorry for the mistake.
nexes
In need of some credit
Posts: 9 Joined: Sat Feb 18, 2006 12:44 am
Post
by nexes » Sun Mar 05, 2006 9:32 pm
Thanks everyone!