PR_Free(unichars);
nsresult ConvertToUnicode(const nsString aCharset,                           const char *inCString,                           nsString &outString){  nsresult res;  NS_WITH_SERVICE(nsICharsetConverterManager, ccm, kCharsetConverterManagerCID, &res);   if(NS_SUCCEEDED(res) && (nsnull != ccm)) {    nsIUnicodeDecoder* decoder = nsnull;    PRUnichar *unichars;    PRInt32 unicharLength;    nsString convCharset;    // map to converter charset    if (aCharset.EqualsIgnoreCase("us-ascii")) {      convCharset.SetString("iso-8859-1");    }    else {      convCharset = aCharset;     }    // get an unicode converter    res = ccm->GetUnicodeDecoder(&convCharset, &decoder);    if(NS_SUCCEEDED(res) && (nsnull != decoder)) {      PRInt32 srcLen = PL_strlen(inCString);      res = decoder->Length(inCString, 0, srcLen, &unicharLength);      // allocale an output buffer      unichars = (PRUnichar *) PR_Malloc(unicharLength * sizeof(PRUnichar));      if (unichars != nsnull) {        // convert to unicode        res = decoder->Convert(unichars, 0, &unicharLength, inCString, 0, &srcLen);        outString.SetString(unichars, unicharLength);      }      else {        res = NS_ERROR_OUT_OF_MEMORY;      }      NS_IF_RELEASE(decoder);    }      }    return res;}