tier1/strtools.cpp
int _V_UCS2ToUnicode( const ucs2 *pUCS2, wchar_t *pUnicode, int cubDestSizeInBytes )
{
	Assert( cubDestSizeInBytes >= sizeof( *pUnicode ) );
	
	pUnicode[0] = 0;
#ifdef _WIN32
	int cchResult = V_wcslen( pUCS2 );
	V_memcpy( pUnicode, pUCS2, cubDestSizeInBytes );
#else
	iconv_t conv_t = iconv_open( "UCS-4LE", "UCS-2LE" );
	int cchResult = -1;
	size_t nLenUnicde = cubDestSizeInBytes;
	size_t nMaxUTF8 = cubDestSizeInBytes;
	char *pIn = (char *)pUCS2;
	char *pOut = (char *)pUnicode;
	if ( conv_t > (iconv_t)0 )
	{
		cchResult = 0;
		cchResult = iconv( conv_t, &pIn, &nLenUnicde, &pOut, &nMaxUTF8 );
		iconv_close( conv_t );
		if ( (int)cchResult < 0 )
			cchResult = 0;
		else
			cchResult = nMaxUTF8;
	}
#endif
	pUnicode[(cubDestSizeInBytes / sizeof(wchar_t)) - 1] = 0;
	return cchResult;	

}
//-----------------------------------------------------------------------------
// Purpose: Converts a ucs2 string to a unicode (wchar_t) one, no-op on win32
//-----------------------------------------------------------------------------
Converts a ucs2 string to a unicode (wchar_t) one, no-op on win32
Converts a ucs2 string to a unicode ( wchar_t ) one no - op on win32
int _V_UCS2ToUnicode( const ucs2 *pUCS2, wchar_t *pUnicode, int cubDestSizeInBytes )
{
	Assert( cubDestSizeInBytes >= sizeof( *pUnicode ) );
	pUnicode[0] = 0;
#ifdef _WIN32
	int cchResult = V_wcslen( pUCS2 );
	V_memcpy( pUnicode, pUCS2, cubDestSizeInBytes );
#else
	iconv_t conv_t = iconv_open( "UCS-4LE", "UCS-2LE" );
	int cchResult = -1;
	size_t nLenUnicde = cubDestSizeInBytes;
	size_t nMaxUTF8 = cubDestSizeInBytes;
	char *pIn = (char *)pUCS2;
	char *pOut = (char *)pUnicode;
	if ( conv_t > (iconv_t)0 )
	{
		cchResult = 0;
		cchResult = iconv( conv_t, &pIn, &nLenUnicde, &pOut, &nMaxUTF8 );
		iconv_close( conv_t );
		if ( (int)cchResult < 0 )
			cchResult = 0;
		else
			cchResult = nMaxUTF8;
	}
#endif
	pUnicode[(cubDestSizeInBytes / sizeof(wchar_t)) - 1] = 0;
	return cchResult;	
}
int _V_UCS2ToUnicode ( const ucs2 * pUCS2 , wchar_t * pUnicode , int cubDestSizeInBytes ) { Assert ( cubDestSizeInBytes >= sizeof ( * pUnicode ) ) ; pUnicode [ 0 ] = 0 ; #ifdef _WIN32 int cchResult = V_wcslen ( pUCS2 ) ; V_memcpy ( pUnicode , pUCS2 , cubDestSizeInBytes ) ; #else iconv_t conv_t = iconv_open ( " " , " " ) ; int cchResult = -1 ; size_t nLenUnicde = cubDestSizeInBytes ; size_t nMaxUTF8 = cubDestSizeInBytes ; char * pIn = ( char * ) pUCS2 ; char * pOut = ( char * ) pUnicode ; if ( conv_t > ( iconv_t ) 0 ) { cchResult = 0 ; cchResult = iconv ( conv_t , & pIn , & nLenUnicde , & pOut , & nMaxUTF8 ) ; iconv_close ( conv_t ) ; if ( ( int ) cchResult < 0 ) cchResult = 0 ; else cchResult = nMaxUTF8 ; } #endif pUnicode [ ( cubDestSizeInBytes / sizeof ( wchar_t ) ) - 1 ] = 0 ; return cchResult ; }
Purpose: Converts a ucs2 string to a unicode (wchar_t) one, no-op on win32
Purpose : Converts a ucs2 string to a unicode ( wchar_t ) one no - op on win32