std::string and unicode
John Ralls
jralls at ceridwen.us
Tue Apr 8 09:02:25 PDT 2008
Yes, it's correct that std::string doesn't support Unicode. Unicode
requires more than one byte per character (except for ASCII characters
in UTF8), so wxChar becomes either 16bit or 32bit (depending on the
platform). You'll have to transcode everything that you need to pass
between std::string and wxString, and you'll have to wrap all of your
literals in wxT macro. See the topic overviews on Unicode support and
Conversion between Unicode and multibyte strings.
There's an alternative, but it requires that you switch to the
development branch. The Unicode support for 2.9/3.0 has been rewritten
to use UTF8, which uses 8-bit wxChar and is therefore somewhat
interoperable with std::string if you're careful about it.
Regards,
John Ralls
On Apr 8, 2008, at 6:44 AM, Declan McMullen wrote:
> Hi Guys,
> I'm slightly confused about something. Does std::string not support
> unicode ?
> I have stl enabled in my wxwidgets compilation. The reason I did it
> is because
> I have some backend classes that use std::string and I didnt want to
> be converting to
> and from std::string to wxString. Turning on stl meant my strings
> could be interchangeable.
>
> However I want to work with locales so I went to use the unicode
> build of wx widgets, this
> however fails to allow me to have interchangeable strings.
>
> So if I want to use unicode will I have to use wxString and perform
> a conversion?
>
> I've been looking through the internationalization section of the
> book but i've ended up confused :)
>
> Any guidance much appreciated.
>
>
>
> --
> http://www.computing.dcu.ie/~dmcmullen
> declan.mcmullen at computing.dcu.ie
> School of Computing
> Postgrad Bay A _______________________________________________
> wx-users mailing list
> wx-users at lists.wxwidgets.org
> http://lists.wxwidgets.org/mailman/listinfo/wx-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.wxwidgets.org/pipermail/wx-users/attachments/20080408/dc56771b/attachment.htm
More information about the wx-users
mailing list