nsAutoString name; NS_CONST_CAST(nsIAtom*, aCharset)->ToString(name); return GetUnicodeEncoder(&name, aResult);
static const char kUnicodeEncoderContractIDBase[] = NS_UNICODEENCODER_CONTRACTID_BASE; static PRInt32 baselen = sizeof(kUnicodeEncoderContractIDBase) - 1;  char contractid[256]; PL_strncpy(contractid, kUnicodeEncoderContractIDBase, 256); aDest->ToCString(contractid + baselen, 256 - baselen);  nsCOMPtr<nsIUnicodeEncoder> encoder;  encoder = do_CreateInstance(contractid, &res);  if (NS_FAILED(res)) res = NS_ERROR_UCONV_NOCONV; else { *aResult = encoder.get(); NS_ADDREF(*aResult); } return res;
NS_IMETHODIMP nsCharsetConverterManager::GetUnicodeEncoder(                                         const nsIAtom * aCharset,                                          nsIUnicodeEncoder ** aResult){  if (aCharset == NULL) return NS_ERROR_NULL_POINTER;  if (aResult == NULL) return NS_ERROR_NULL_POINTER;  *aResult = NULL;  // XXX use nsImmutableString  nsAutoString name;  NS_CONST_CAST(nsIAtom*, aCharset)->ToString(name);  return GetUnicodeEncoder(&name, aResult);}