GetData(dataUni, "search", 0, "queryEncoding", encodingStr); MapEncoding(encodingStr, queryEncodingStr);
GetData(dataUni, "search", 0, "queryCharset", queryEncodingStr); if (queryEncodingStr.Length() < 1) { GetData(dataUni, "search", 0, "queryEncoding", encodingStr); MapEncoding(encodingStr, queryEncodingStr); }
InternetSearchDataSource::GetInternetSearchURL(const char *searchEngineURI,	const PRUnichar *searchStr, char **resultURL){	if (!resultURL)	return(NS_ERROR_NULL_POINTER);	*resultURL = nsnull;	// if we haven't already, load in the engines	if (mEngineListBuilt == PR_FALSE)	DeferredInit();	nsresult			rv;	nsCOMPtr<nsIRDFResource>	engine;	if (NS_FAILED(rv = gRDFService->GetResource(searchEngineURI, getter_AddRefs(engine))))		return(rv);	if (!engine)	return(NS_ERROR_UNEXPECTED);	// if its a engine from a search category, then get its "#Name",	// and try to map from that back to the real engine reference	if (isSearchCategoryEngineURI(engine))	{		nsCOMPtr<nsIRDFResource>	trueEngine;		rv = resolveSearchCategoryEngineURI(engine, getter_AddRefs(trueEngine));		if (NS_FAILED(rv) || (rv == NS_RDF_NO_VALUE))	return(rv);		if (!trueEngine)	return(NS_RDF_NO_VALUE);		engine = trueEngine;	}	nsCOMPtr<nsIRDFLiteral>	dataLit;	if (NS_FAILED(rv = FindData(engine, getter_AddRefs(dataLit))) ||		(rv == NS_RDF_NO_VALUE))	return(rv);	if (!dataLit)	return(NS_ERROR_UNEXPECTED);	const PRUnichar	*dataUni = nsnull;	dataLit->GetValueConst(&dataUni);	if (!dataUni)	return(NS_RDF_NO_VALUE);	nsAutoString	 text(searchStr), encodingStr, queryEncodingStr;	GetData(dataUni, "search", 0, "queryEncoding", encodingStr);	// decimal string values	MapEncoding(encodingStr, queryEncodingStr);	if (queryEncodingStr.Length() > 0)	{		// convert from escaped-UTF_8, to unicode, and then to		// the charset indicated by the dataset in question		char	*utf8data = text.ToNewUTF8String();		if (utf8data)		{			NS_WITH_SERVICE(nsITextToSubURI, textToSubURI,				kTextToSubURICID, &rv);			if (NS_SUCCEEDED(rv) && (textToSubURI))			{				PRUnichar	*uni = nsnull;				if (NS_SUCCEEDED(rv = textToSubURI->UnEscapeAndConvert("UTF-8", utf8data, &uni)) && (uni))				{					char		*charsetData = nsnull;					nsCAutoString	queryencodingstrC;					queryencodingstrC.AssignWithConversion(queryEncodingStr);					if (NS_SUCCEEDED(rv = textToSubURI->ConvertAndEscape(queryencodingstrC, uni, &charsetData)) && (charsetData))					{						text.AssignWithConversion(charsetData);						Recycle(charsetData);					}					Recycle(uni);				}			}			Recycle(utf8data);		}	}		nsAutoString	action, input, method, userVar;	if (NS_FAILED(rv = GetData(dataUni, "search", 0, "action", action)))	return(rv);	if (NS_FAILED(rv = GetData(dataUni, "search", 0, "method", method)))	return(rv);	if (NS_FAILED(rv = GetInputs(dataUni, userVar, text, input)))	return(rv);	if (input.Length() < 1)				return(NS_ERROR_UNEXPECTED);	// we can only handle HTTP GET	if (!method.EqualsIgnoreCase("get"))	return(NS_ERROR_UNEXPECTED);	// HTTP Get method support	action.AppendWithConversion("?");	action += input;	// return a copy of the resulting search URL	*resultURL = action.ToNewCString();	return(NS_OK);}