How to convert wxString to unsigned char *

35 views
Skip to first unread message

iko...@earthlink.net

unread,
Nov 22, 2009, 3:05:08 AM11/22/09
to wx-u...@googlegroups.com
Hi, ALL,
I can perform a conversion from unsigned char *
to wxString using FromAscii(), but I don't know/can't
find the way to convert other way around.

Thank you.

Eran Ifrah

unread,
Nov 22, 2009, 3:08:29 AM11/22/09
to wx-u...@googlegroups.com
You can try:
string.mb_str(wxConvUTF8).data()
( you can use other conversions, but wxConvUTF8 will do the work for
most cases)
but it returns char* and not unsinged char*

but it works for me
--
Eran Ifrah
Cross platform, open source C++ IDE: http://www.codelite.org

iko...@earthlink.net

unread,
Nov 22, 2009, 3:38:55 PM11/22/09
to wx-u...@googlegroups.com
Hi, Eran,

-----Original Message-----
>From: Eran Ifrah <eran....@gmail.com>
>Sent: Nov 22, 2009 12:08 AM
>To: wx-u...@googlegroups.com
>Subject: Re: How to convert wxString to unsigned char *
>
>
>You can try:
>string.mb_str(wxConvUTF8).data()
> ( you can use other conversions, but wxConvUTF8 will do the work for
>most cases)
>but it returns char* and not unsinged char*
>
>but it works for me

No, it does not work for me.
I need an "unsigned char *" as I will cast it to "SQLCHAR *", which is, I think,
7-bit ASCII.

Any other ideas?

Thank you.

Lauri Nurmi

unread,
Nov 23, 2009, 3:49:48 AM11/23/09
to wx-u...@googlegroups.com
Hi,

Could you please use a mail client that doesn't mess up the thread every
time you reply? Your replies always start a new thread.

Thanks.

Domingo Becker

unread,
Nov 23, 2009, 9:45:33 AM11/23/09
to wx-u...@googlegroups.com
2009/11/22 <iko...@earthlink.net>:

>
> Hi, Eran,
>
> -----Original Message-----
>>From: Eran Ifrah <eran....@gmail.com>
>>Sent: Nov 22, 2009 12:08 AM
>>To: wx-u...@googlegroups.com
>>Subject: Re: How to convert wxString to unsigned char *
>>
>>
>>You can try:
>>string.mb_str(wxConvUTF8).data()
>> ( you can use other conversions, but wxConvUTF8 will do the work for
>>most cases)
>>but it returns char* and not unsinged char*
>>
>>but it works for me
>
> No, it does not work for me.
> I need an "unsigned char *" as I will cast it to "SQLCHAR *", which is, I think,
> 7-bit ASCII.
>
> Any other ideas?
>

(const char *) thestring.mb_str()

Reply all
Reply to author
Forward
0 new messages