Skip to content

Instantly share code, notes, and snippets.

@rechardchen
rechardchen / unicode_utf8.cc
Created August 11, 2012 06:30
C++: convert between utf8 and unicode
wstring UTF8toUnicode(const string& s)
{
wstring ws;
wchar_t wc;
for( int i = 0;i < s.length(); )
{
char c = s[i];
if ( (c & 0x80) == 0 )
{
wc = c;