Пример #1
0
String CacheFileFromUrl(const String &url) {
	Md5Hash hash;
	ByteBuffer *utf8url = StringUtil::StringToUtf8N(url);
	hash.Initialize();
	hash.Update(*utf8url);
	ByteBuffer *hashBuffer = hash.FinalizeN();

	String hashString(VKUApp::GetInstance()->GetCacheDir());
	byte currentByte;
	while(hashBuffer->GetRemaining() > 0) {
		hashBuffer->GetByte(currentByte);
		hashString.Append(hexTable[currentByte]);
	}
	hashString.Append(".jpg");

	delete utf8url;
	delete hashBuffer;

	return hashString;
}
Пример #2
0
static KDbool convString2Utf8 ( KDchar* pszDst, KDsize uMaxLen, String strSrc )
{
	ByteBuffer*  pBuff = KD_NULL;
	KDsize       uCnt  = 0;

	pBuff = StringUtil::StringToUtf8N ( strSrc );
	if ( !pBuff )
	{
		goto end;
	}

	while ( pBuff->HasRemaining ( ) )
	{
		byte   b;
		pBuff->GetByte ( b );

		if ( uCnt < ( uMaxLen - 1 ) )
		{
			pszDst [ uCnt++ ] = b;
		}
		else
		{
			break;
		}
	}

	pszDst [ uCnt ] = '\0';

end :

	if ( pBuff )
	{
		delete pBuff;
	}


	return KD_TRUE;
}