if (!aHTMLEditor) { aEditor->InsertText(aBuf.GetUnicode());  return NS_OK; }
ConvertAndLoadComposeWindow(nsIEditorShell *aEditor, nsString aBuf, PRBool aQuoted, PRBool aHTMLEditor){  nsresult            res;  nsString            inputCharset("UTF-8");   nsIUnicodeDecoder   *decoder = nsnull;  PRInt32             unicharLength = 0;  PRUnichar           *unicodeInputString = nsnull;   // Unicode version of input  char                *inputString = nsnull;          // original string...  PRInt32             inputStringLength;        // If this is text compose, just insert what we have into the editor  if (!aHTMLEditor)  {    aEditor->InsertText(aBuf.GetUnicode());/* RICHIE SHERRY - InsertAsQuotation on a plain text editor is not working yet!    if (aQuoted)      aEditor->InsertAsQuotation(aBuf.GetUnicode());    else      aEditor->InsertText(aBuf.GetUnicode());***/    return NS_OK;  }  // Get the service for charset conversion...  NS_WITH_SERVICE(nsICharsetConverterManager, ccm, kCharsetConverterManagerCID, &res);   if (NS_FAILED(res) || !ccm)    return NS_ERROR_FAILURE;  // Get the decoder to go from UTF-8 to Unicode...  ccm->GetUnicodeDecoder(&inputCharset, &decoder);  if (!decoder)    return NS_ERROR_FAILURE;  // RICHIE  // This could go away....getting the aBuf in oneByteChar format...  inputString = aBuf.ToNewCString();  inputStringLength = (PRInt32) nsCRT::strlen(inputString);  // Get the maximum output length and create the output buffer...  res = decoder->GetMaxLength(inputString, inputStringLength, &unicharLength);   unicodeInputString = (PRUnichar *) PR_Malloc((unicharLength + 1) * sizeof(PRUnichar));  if (!unicodeInputString)  {    PR_FREEIF(inputString);    return NS_ERROR_FAILURE;  }  nsCRT::memset(unicodeInputString, 0, ((unicharLength + 1) * sizeof(PRUnichar)));  res = decoder->Convert(inputString, &inputStringLength, unicodeInputString, &unicharLength);   if (NS_FAILED(res))  {    PR_FREEIF(inputString);    PR_FREEIF(unicodeInputString);    return NS_ERROR_FAILURE;  }  // Now, insert it into the editor the correct way!  if (aQuoted)    aEditor->InsertAsQuotation(unicodeInputString);  else  {    if (aHTMLEditor)      aEditor->InsertSource(unicodeInputString);    else      aEditor->InsertText(unicodeInputString);  }  PR_FREEIF(inputString);  PR_FREEIF(unicodeInputString);  return NS_OK;}