tier1/strtools.cpp
int _V_UnicodeToUTF8( const wchar_t *pUnicode, char *pUTF8, int cubDestSizeInBytes )
{
	if ( cubDestSizeInBytes > 0 )
	{
		pUTF8[0] = 0;
	}

#ifdef _WIN32
	int cchResult = WideCharToMultiByte( CP_UTF8, 0, pUnicode, -1, pUTF8, cubDestSizeInBytes, NULL, NULL );
#elif POSIX
	int cchResult = 0;
	if ( pUnicode && pUTF8 )
		cchResult = wcstombs( pUTF8, pUnicode, cubDestSizeInBytes );
#endif

	if ( cubDestSizeInBytes > 0 )
	{
		pUTF8[cubDestSizeInBytes - 1] = 0;
	}

	return cchResult;
}
//-----------------------------------------------------------------------------
// Purpose: Converts a unicode string into a UTF8 (standard) string
//-----------------------------------------------------------------------------
Converts a unicode string into a UTF8 (standard) string
Converts a unicode string into a UTF8 ( standard ) string
int _V_UnicodeToUTF8( const wchar_t *pUnicode, char *pUTF8, int cubDestSizeInBytes )
{
	if ( cubDestSizeInBytes > 0 )
	{
		pUTF8[0] = 0;
	}
#ifdef _WIN32
	int cchResult = WideCharToMultiByte( CP_UTF8, 0, pUnicode, -1, pUTF8, cubDestSizeInBytes, NULL, NULL );
#elif POSIX
	int cchResult = 0;
	if ( pUnicode && pUTF8 )
		cchResult = wcstombs( pUTF8, pUnicode, cubDestSizeInBytes );
#endif
	if ( cubDestSizeInBytes > 0 )
	{
		pUTF8[cubDestSizeInBytes - 1] = 0;
	}
	return cchResult;
}
int _V_UnicodeToUTF8 ( const wchar_t * pUnicode , char * pUTF8 , int cubDestSizeInBytes ) { if ( cubDestSizeInBytes > 0 ) { pUTF8 [ 0 ] = 0 ; } #ifdef _WIN32 int cchResult = WideCharToMultiByte ( CP_UTF8 , 0 , pUnicode , -1 , pUTF8 , cubDestSizeInBytes , NULL , NULL ) ; #elif POSIX int cchResult = 0 ; if ( pUnicode && pUTF8 ) cchResult = wcstombs ( pUTF8 , pUnicode , cubDestSizeInBytes ) ; #endif if ( cubDestSizeInBytes > 0 ) { pUTF8 [ cubDestSizeInBytes - 1 ] = 0 ; } return cchResult ; }
Purpose: Converts a unicode string into a UTF8 (standard) string
Purpose : Converts a unicode string into a UTF8 ( standard ) string