rv = nsComponentManager::CreateInstance(kCParserCID, nsnull, NS_GET_IID(nsIParser), getter_AddRefs(parser));
nsresult rv; nsCOMPtr<nsIParser> parser = do_CreateInstance(kCParserCID, &rv);
ConvertBufToPlainText(nsString &aConBuf, PRBool formatflowed /* = PR_FALSE */){  nsresult    rv;  nsString    convertedText;  nsCOMPtr<nsIParser> parser;  if (aConBuf.IsEmpty())    return NS_OK;  rv = nsComponentManager::CreateInstance(kCParserCID, nsnull,                                           NS_GET_IID(nsIParser), getter_AddRefs(parser));  if (NS_SUCCEEDED(rv) && parser)  {    PRUint32 converterFlags = 0;    PRUint32 wrapWidth = 72;        converterFlags |= nsIDocumentEncoder::OutputFormatted;    /*    */    if(formatflowed)      converterFlags |= nsIDocumentEncoder::OutputFormatFlowed;        nsCOMPtr<nsIContentSink> sink;    sink = do_CreateInstance(NS_PLAINTEXTSINK_CONTRACTID);    NS_ENSURE_TRUE(sink, NS_ERROR_FAILURE);    nsCOMPtr<nsIHTMLToTextSink> textSink(do_QueryInterface(sink));    NS_ENSURE_TRUE(textSink, NS_ERROR_FAILURE);    textSink->Initialize(&convertedText, converterFlags, wrapWidth);    parser->SetContentSink(sink);    parser->Parse(aConBuf, 0, NS_LITERAL_CSTRING("text/html"), PR_FALSE, PR_TRUE);    //    // Now if we get here, we need to get from ASCII text to     // UTF-8 format or there is a problem downstream...    //    if (NS_SUCCEEDED(rv))    {      aConBuf = convertedText;    }  }  return rv;}