char* inTypeStr = inType.ToNewCString();
char* inTypeStr = ToNewCString(inType);
HTML2text(nsString& inString, nsString& inType, nsString& outType,          int flags, int wrapCol, nsString& compareAgainst){  nsresult rv = NS_OK;  nsString outString;  // Create a parser  nsIParser* parser;   rv = nsComponentManager::CreateInstance(kParserCID, nsnull,                                           kIParserIID,(void**)&parser);  if (NS_FAILED(rv))  {    printf("Unable to create a parser : 0x%x\n", rv);    return NS_ERROR_FAILURE;  }  // Create the appropriate output sink#ifdef USE_SERIALIZER  nsCAutoString progId(NS_CONTENTSERIALIZER_CONTRACTID_PREFIX);  progId.AppendWithConversion(outType);  // The syntax used here doesn't work  nsCOMPtr<nsIContentSerializer> mSerializer;  mSerializer = do_CreateInstance(NS_STATIC_CAST(const char *, progId));  NS_ENSURE_TRUE(mSerializer, NS_ERROR_NOT_IMPLEMENTED);  mSerializer->Init(flags, wrapCol);  nsCOMPtr<nsIHTMLContentSink> sink (do_QueryInterface(mSerializer));  if (!sink)  {    printf("Couldn't get content sink!\n");    return NS_ERROR_UNEXPECTED;  }#else /* USE_SERIALIZER */  nsCOMPtr<nsIContentSink> sink;  if (inType != NS_LITERAL_STRING("text/html")      || outType != NS_LITERAL_STRING("text/plain"))  {    char* in = inType.ToNewCString();    char* out = outType.ToNewCString();    printf("Don't know how to convert from %s to %s\n", in, out);    Recycle(in);    Recycle(out);    return NS_ERROR_FAILURE;  }  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(&outString, flags, wrapCol);#endif /* USE_SERIALIZER */  parser->SetContentSink(sink);   nsCOMPtr<nsIDTD> dtd;  if (inType.EqualsWithConversion("text/html")) {    static NS_DEFINE_CID(kNavDTDCID, NS_CNAVDTD_CID);    rv=nsComponentManager::CreateInstance(kNavDTDCID,nsnull,NS_GET_IID(nsIDTD),getter_AddRefs(dtd));  }  else  {    printf("Don't know how to deal with non-html input!\n");    return NS_ERROR_NOT_IMPLEMENTED;  }  if (NS_FAILED(rv))  {    printf("Couldn't create new HTML DTD: 0x%x\n", rv);    return rv;  }  parser->RegisterDTD(dtd);  char* inTypeStr = inType.ToNewCString();  rv = parser->Parse(inString, 0, NS_ConvertASCIItoUCS2(inTypeStr), PR_FALSE, PR_TRUE);  delete[] inTypeStr;  if (NS_FAILED(rv))  {    printf("Parse() failed! 0x%x\n", rv);    return rv;  }  NS_RELEASE(parser);  if (compareAgainst.Length() > 0)    return Compare(outString, compareAgainst);  char* charstar = outString.ToNewUTF8String();  printf("Output string is:\n--------------------\n%s--------------------\n",         charstar);  delete[] charstar;  return NS_OK;}