std::string and unicode

Vadim Zeitlin vadim at wxwidgets.org
Tue Apr 8 10:31:16 PDT 2008


On Tue, 8 Apr 2008 18:20:50 +0100 Declan McMullen <declan.mcmullen at gmail.com> wrote:

DM> This guy actually wrote two nice little functions
DM> http://www.kangmaman.com/node/131

 I think you could make it even more complicated but I must admit that at a
first glance I don't see how. I'd also strongly recommend deciding upon
your std::string encoding instead of blindly trying UTF-8 first and falling
back to ASCII later (and what happens if it's in Latin-1? or koi8-r?) --
and it also would be better if conversion in both directions were symmetric
which is not the case here. And I won't even mention nice pessimizations
like not passing strings via references and especially creating a temporary
object on a heap instead of just using wxConvUTF8...

 In short, don't use the code above.

 Regards,
VZ

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



More information about the wx-users mailing list