c++windowscodecvt

How do I write a std::codecvt facet?


How do I write a std::codecvt facet? I'd like to write ones that go from UTF-16 to UTF-8, which go from UTF-16 to the systems current code page (windows, so CP_ACP), and to the system's OEM codepage (windows, so CP_OEM).

Cross-platform is preferred, but MSVC on Windows is fine too. Are there any kinds of tutorials or anything of that nature on how to correctly use this class?


Solution

  • I've written one based on iconv. It can be used on windows or on any POSIX OS. (You will need to link with iconv obviously).

    Enjoy

    The answer for the "how to" question is to follow the codecvt reference. I was not able to find any better instructions in the Internet two years ago.

    Important notices