DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

WcharToString

08.05.2010
| 1433 views |
  • submit to reddit
        // description of your code here

#include <string>
#include <locale>
using namespace std;


string wcharToString ( wchar_t *pp )
{
    locale loc;
    char pc[1024];
    wstring bb ( pp );
    use_facet< ctype<wchar_t> >(loc).narrow ( bb.c_str(), bb.c_str()+bb.size()+1, '?', pc);
    return string ( pc );
}