From: "Marc de Kamps" on
Hi,

I'm a novel user of wxGTK. I have to port some legacy code to the latest
version that we use here 2.8 on a FEDORA linux platform compiled with
Unicode support. The old code used version 2.4.2.

One of the main differences appear to be that there is no more implicit
conversion from (ANSI) C strings to wxString

I have read the documentation under Unicode:

- I understand that literals can be converted using the _T() macro and that
this will be expanded into the correct format whether one uses Unicode
support or not.

- I understand that when I need an ANSI C string, for example because it
needs to be converted to an STL string, I can use mb_str().

What I do not understand is how an ANSI C string that is not a literal
should be converted into a wxString, for example,
I've been passed an STL string str_example and apparently I need a converter
object to convert into a wxString object:

wxString wx_example(str_example.c_str(),*wxConvCurrent);

How do I do determine which converter I need?

Thanks,
Marc

---------------------------------------------------------------------
To unsubscribe, e-mail: wx-users-unsubscribe(a)lists.wxwidgets.org
For additional commands, e-mail: wx-users-help(a)lists.wxwidgets.org

From: "Steven Van Ingelgem" on
Generally you only need the current convertor unless you know yourself
you need utf8/7/16/other convertor. It's up to you to know what you
pass as the convertor. If you're complete program is using UTF8 (you
mentioned gtk right) then i'd say, just use the UTF8 convertor
(wxConvUTF8).


Hope this helps

On 04/01/2008, Marc de Kamps <dekamps(a)comp.leeds.ac.uk> wrote:
> Hi,
>
> I'm a novel user of wxGTK. I have to port some legacy code to the latest
> version that we use here 2.8 on a FEDORA linux platform compiled with
> Unicode support. The old code used version 2.4.2.
>
> One of the main differences appear to be that there is no more implicit
> conversion from (ANSI) C strings to wxString
>
> I have read the documentation under Unicode:
>
> - I understand that literals can be converted using the _T() macro and that
> this will be expanded into the correct format whether one uses Unicode
> support or not.
>
> - I understand that when I need an ANSI C string, for example because it
> needs to be converted to an STL string, I can use mb_str().
>
> What I do not understand is how an ANSI C string that is not a literal
> should be converted into a wxString, for example,
> I've been passed an STL string str_example and apparently I need a converter
> object to convert into a wxString object:
>
> wxString wx_example(str_example.c_str(),*wxConvCurrent);
>
> How do I do determine which converter I need?
>
> Thanks,
> Marc
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: wx-users-unsubscribe(a)lists.wxwidgets.org
> For additional commands, e-mail: wx-users-help(a)lists.wxwidgets.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: wx-users-unsubscribe(a)lists.wxwidgets.org
For additional commands, e-mail: wx-users-help(a)lists.wxwidgets.org

From: Vadim Zeitlin on
On Fri, 4 Jan 2008 12:29:06 -0000 Marc de Kamps <dekamps(a)comp.leeds.ac.uk> wrote:

MdK> I'm a novel user of wxGTK. I have to port some legacy code to the latest
MdK> version that we use here 2.8 on a FEDORA linux platform compiled with
MdK> Unicode support. The old code used version 2.4.2.
MdK>
MdK> One of the main differences appear to be that there is no more implicit
MdK> conversion from (ANSI) C strings to wxString

This is true in Unicode build but not in ANSI one. You can still build
even 2.8 in ANSI mode and while this does mean that you won't be able to
handle non-ASCII characters easily, if it's not a problem for you, it's
probably much simpler to just do this than to update your legacy code.

MdK> What I do not understand is how an ANSI C string that is not a literal
MdK> should be converted into a wxString, for example,
MdK> I've been passed an STL string str_example and apparently I need a converter
MdK> object to convert into a wxString object:
MdK>
MdK> wxString wx_example(str_example.c_str(),*wxConvCurrent);
MdK>
MdK> How do I do determine which converter I need?

This is determined solely by the encoding of the original string. If it's
(7 bit) ASCII, you can just use wxString::FromAscii(). If it's an 8 bit
string in current locale, then wxConvCurrent is what you need. If it's in
UTF-8, then you need wxConvUTF8.

Regards,
VZ

--
TT-Solutions: wxWidgets consultancy and technical support
http://www.tt-solutions.com/

---------------------------------------------------------------------
To unsubscribe, e-mail: wx-users-unsubscribe(a)lists.wxwidgets.org
For additional commands, e-mail: wx-users-help(a)lists.wxwidgets.org