else if (NS_SUCCEEDED(prefs->GetLocalizedUnicharPref("intl.charset.detector", &detector_name))) { PL_strcat(detector_contractid, NS_ConvertUCS2toUTF8(detector_name).get());
else if (NS_SUCCEEDED(prefs->CopyCharPref("intl.charset.detector", &detector_name))) { PL_strcat(detector_progid, detector_name);
PRInt32 MimeCharsetConverterClass::Initialize(const char* from_charset, const char* to_charset,                                               const PRBool autoDetect, const PRInt32 maxNumCharsDetect){  nsresult res;  NS_ASSERTION(NULL == mEncoder, "No reinitialization allowed.");  mInputCharset.AssignWithConversion(from_charset);     // remember input charset for a hint  if (mInputCharset.IsEmpty()) {    mInputCharset.AssignWithConversion("ISO-8859-1");  }  mOutputCharset.AssignWithConversion(to_charset);      // remember output charset  if (mOutputCharset.IsEmpty()) {    mOutputCharset.AssignWithConversion("UTF-8");  }  mAutoDetect = autoDetect;  mMaxNumCharsDetect = maxNumCharsDetect;  // Resolve charset alias  nsCOMPtr<nsICharsetAlias> calias(do_GetService(kCharsetAliasCID, &res));   if (NS_SUCCEEDED(res)) {    nsString aAlias(mInputCharset);    if (aAlias.Length()) {      res = calias->GetPreferred(aAlias, mInputCharset);      if (NS_FAILED(res)) {        mInputCharset.AssignWithConversion("ISO-8859-1");      }    }    aAlias = mOutputCharset;    if (aAlias.Length()) {      res = calias->GetPreferred(aAlias, mOutputCharset);      if (NS_FAILED(res)) {        mOutputCharset.AssignWithConversion("UTF-8");      }    }  }  if (mAutoDetect) {    char detector_contractid[128];    PRUnichar* detector_name = nsnull;    PL_strcpy(detector_contractid, NS_STRCDETECTOR_CONTRACTID_BASE);    nsCOMPtr<nsIPref> prefs(do_GetService(kPrefCID, &res));     if (NS_SUCCEEDED(res)) {      if (NS_SUCCEEDED(prefs->CopyUnicharPref("mail.charset.detector", &detector_name))) {        PL_strcat(detector_contractid, NS_ConvertUCS2toUTF8(detector_name).get());        PR_FREEIF(detector_name);      }      else if (NS_SUCCEEDED(prefs->GetLocalizedUnicharPref("intl.charset.detector", &detector_name))) {        PL_strcat(detector_contractid, NS_ConvertUCS2toUTF8(detector_name).get());        PR_FREEIF(detector_name);      }    }    if (!mDetectorContractID.Equals(detector_contractid)) {      // may have multi-thread issue updating these static variables      // but charset detector can only be changed globally through UI      NS_IF_RELEASE(mDetector);      mDetectorContractID.Assign("");      // create instance when the detector name is not empty      if (nsCRT::strcmp(detector_contractid, NS_STRCDETECTOR_CONTRACTID_BASE)) {        res = nsComponentManager::CreateInstance(detector_contractid, nsnull,                                                  NS_GET_IID(nsIStringCharsetDetector), (void**)&mDetector);        if (NS_SUCCEEDED(res)) {          mDetectorContractID.Assign(detector_contractid);        }      }    }  }  // No need to do the conversion then do not create converters.   if (!mAutoDetect && !NeedCharsetConversion(mInputCharset, mOutputCharset)) {    return 0;  }  // Set up charset converters.  nsCOMPtr<nsICharsetConverterManager> ccm =            do_GetService(kCharsetConverterManagerCID, &res);   if (NS_SUCCEEDED(res)) {    // create a decoder (conv to unicode), ok if failed if we do auto detection    res = ccm->GetUnicodeDecoder(&mInputCharset, &mDecoder);    if (NS_SUCCEEDED(res) || mAutoDetect) {      // create an encoder (conv from unicode)      res = ccm->GetUnicodeEncoder(&mOutputCharset, &mEncoder);    }  }  return NS_SUCCEEDED(res) ? 0 : -1;}