nsCAutoString charset; rv = doc->GetDocumentCharacterSet(charset); NS_ASSERTION(NS_SUCCEEDED(rv), "can't get charset"); if (NS_FAILED(rv)) return rv;
const nsACString &charset = doc->GetDocumentCharacterSet();
NS_IMETHODIMP nsPluginInstanceOwner::GetDocumentEncoding(const char* *result){  NS_ENSURE_ARG_POINTER(result);  *result = nsnull;  nsresult rv;  nsCOMPtr<nsIDocument> doc;  rv = GetDocument(getter_AddRefs(doc));  NS_ASSERTION(NS_SUCCEEDED(rv), "failed to get document");  if (NS_FAILED(rv)) return rv;  nsCAutoString charset;  rv = doc->GetDocumentCharacterSet(charset);  NS_ASSERTION(NS_SUCCEEDED(rv), "can't get charset");  if (NS_FAILED(rv)) return rv;  if (charset.IsEmpty()) return NS_OK;  // common charsets and those not requiring conversion first  if (charset == NS_LITERAL_CSTRING("us-acsii")) {    *result = PL_strdup("US_ASCII");  } else if (charset == NS_LITERAL_CSTRING("ISO-8859-1") ||      !nsCRT::strncmp(charset.get(), "UTF", 3)) {    *result = ToNewCString(charset);  } else {    if (!gCharsetMap) {      gCharsetMap = new nsHashtable(sizeof(charsets)/sizeof(moz2javaCharset));      if (!gCharsetMap) return NS_ERROR_OUT_OF_MEMORY;      for (PRUint16 i = 0; i < sizeof(charsets)/sizeof(moz2javaCharset); i++) {        nsCStringKey key(charsets[i].mozName);        gCharsetMap->Put(&key, (void *)(charsets[i].javaName));      }    }    nsCStringKey mozKey(charset);    // if found mapping, return it; otherwise return original charset    char *mapping = (char *)gCharsetMap->Get(&mozKey);    *result = mapping ? PL_strdup(mapping) : ToNewCString(charset);  }  return (*result) ? NS_OK : NS_ERROR_OUT_OF_MEMORY;}