
On Mon, Jun 15, 2009 at 10:45 AM, Robert Dailey
On Mon, Jun 15, 2009 at 3:55 AM, Boris Schaeling
wrote: On Sun, 14 Jun 2009 21:41:16 +0200, Robert Dailey
wrote: [...]Great advice Zach. I'll definitely do this. However, it would be nice to have an already-made conversion routine for UTF8 to UTF16. I'm hoping
The conversion routines you are looking for are std::mbsrtowcs() and std::wcsrtombs() in <cwchar>. You must set the global locale first before you use them so they know which multi-byte encoding they should use (try for example "en_US.UTF-8"). If you want your application to work on Windows, too, you can't use those functions unfortunately but must use MultiByteToWideChar() and WideCharToMultiByte() instead (as there is no UTF-8 locale on Windows).
The Unicode FAQ for Unix and Linux might also help: http://www.cl.cam.ac.uk/~mgk25/unicode.html
Boris, This is a good idea. I had thought about this, but I was hoping there was a more portable solution already out there. If not, then I could just create a simple abstraction for the platform specific routines. Thanks for your help (And to everyone else as well)!
The probelm with this approach, if I'm not mistaken, is that different encodings have different names across operating systems, and even across different linux distros. So if you see en_US.UTF-8 on one distro, it might be something else on another distro. Correct me if I'm wrong