Discussion:
wxString to char* Is this correct?
'Sudheer Palaparambil' via wx-users
2014-06-07 01:07:03 UTC
Permalink
Dear friends,

I found the following code at http://blog.sina.com.cn/s/blog_4fcd1ea30100x3fs.html
Is this is the correct way to convert?


//convert wxString to char *
wxString str = wxT("One");
//test
char c1[1024];
//use malloc to create 'c1'
//int len = str.Length() + 1;
//char *c1 = (char *)malloc(len*sizeof(char));
//assuming you want UTF-8, change the wxConv* parameter as needed
strncpy(c1, str.mb_str(wxConvUTF8), 1023);

Thanks and regards.
Sudheer Palaparambil
--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.

To unsubscribe, send email to wx-users+***@googlegroups.com
or visit http://groups.google.com/group/wx-users
Ashish More
2014-06-07 01:16:48 UTC
Permalink
http://wiki.wxwidgets.org/Converting_everything_to_and_from_wxString
Post by 'Sudheer Palaparambil' via wx-users
Dear friends,
I found the following code at
http://blog.sina.com.cn/s/blog_4fcd1ea30100x3fs.html
Is this is the correct way to convert?
//convert wxString to char *
wxString str = wxT("One");
//test
char c1[1024];
//use malloc to create 'c1'
//int len = str.Length() + 1;
//char *c1 = (char *)malloc(len*sizeof(char));
//assuming you want UTF-8, change the wxConv* parameter as needed
strncpy(c1, str.mb_str(wxConvUTF8), 1023);
Thanks and regards.
Sudheer Palaparambil
--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.

To unsubscribe, send email to wx-users+***@googlegroups.com
or visit http://groups.google.com/group/wx-users
Loading...