Posts Tagged ‘c’


Convert Unicode To UTF8

char* __stdcall UnicodeToUtf8( const WCHAR* wstr )
{
    const WCHAR* w;
    // Convert unicode to utf8
    int len = 0;
    for ( w = wstr; *w; w++ ) {

        if ( *w < 0×0080 ) len++;
        else if ( *w < 0×0800 ) len += 2;
        else len += 3;
    }

September 24th, 2006 in Programming | 24 comments