nsAutoString charset(aCharset); NS_WITH_SERVICE(nsICharsetAlias, csAlias, kCharsetAliasCID, &res); NS_ASSERTION(NS_SUCCEEDED(res), "failed to get the CharsetAlias service"); if (NS_SUCCEEDED(res)) {
nsDependentString charset(aCharset); nsCOMPtr<nsICharsetAlias> csAlias( do_GetService(kCharsetAliasCID) ); NS_ASSERTION(csAlias, "failed to get the CharsetAlias service"); if (csAlias) {
NS_IMETHODIMP nsCharsetConverterManager::GetCharsetAtom(                                         const PRUnichar * aCharset,                                          nsIAtom ** aResult){  if (aCharset == NULL) return NS_ERROR_NULL_POINTER;  if (aResult == NULL) return NS_ERROR_NULL_POINTER;  *aResult = NULL;  nsresult res;  // We try to obtain the preferred name for this charset from the charset   // aliases. If we don't get it from there, we just use the original string  nsAutoString charset(aCharset);  NS_WITH_SERVICE(nsICharsetAlias, csAlias, kCharsetAliasCID, &res);  NS_ASSERTION(NS_SUCCEEDED(res), "failed to get the CharsetAlias service");  if (NS_SUCCEEDED(res)) {    nsAutoString pref;    res = csAlias->GetPreferred(charset, pref);    if (NS_SUCCEEDED(res)) {      charset.Assign(pref);    }  }  // turn that cannonical name into an Atom  nsCOMPtr<nsIAtom> atom =  getter_AddRefs(NS_NewAtom(charset));  if (atom.get() == NULL) {    return NS_ERROR_OUT_OF_MEMORY;  }  // everything was fine, set the result  *aResult = atom;  NS_ADDREF(*aResult);  return NS_OK;}