text->defaultCharset = NS_ConvertUCS2toUTF8(value).ToNewCString(); nsMemory::Free(value);
text->defaultCharset = ToNewUTF8String(value);
MimeInlineText_initialize (MimeObject *obj){  MimeInlineText *text = (MimeInlineText *) obj;    /* This is an abstract class; it shouldn't be directly instanciated. */  PR_ASSERT(obj->clazz != (MimeObjectClass *) &mimeInlineTextClass);    /* Figure out an appropriate charset for this object.  */  if (!text->charset && obj->headers)  {    if (obj->options && obj->options->override_charset)    {      text->charset = nsCRT::strdup(obj->options->default_charset);    }    else    {      char *ct = MimeHeaders_get (obj->headers, HEADER_CONTENT_TYPE,                                  PR_FALSE, PR_FALSE);      if (ct)      {        text->charset = MimeHeaders_get_parameter (ct, "charset", NULL, NULL);        PR_Free(ct);      }          if (!text->charset)      {        /* If we didn't find "Content-Type: ...; charset=XX" then look           for "X-Sun-Charset: XX" instead.  (Maybe this should be done           in MimeSunAttachmentClass, but it's harder there than here.)         */        text->charset = MimeHeaders_get (obj->headers,                                          HEADER_X_SUN_CHARSET,                                          PR_FALSE, PR_FALSE);      }      if (!text->charset)      {        if (obj->options && obj->options->default_charset)          text->charset = nsCRT::strdup(obj->options->default_charset);        else        {          // New change for falling back to a default view charset          nsresult        rv;          nsCOMPtr<nsIPref> prefs(do_GetService(kPrefServiceCID, &rv));          if ( NS_SUCCEEDED(rv) && prefs)          {            PRUnichar* value;            rv = prefs->GetLocalizedUnicharPref("mailnews.view_default_charset", &value);            if(NS_SUCCEEDED(rv)) {              text->defaultCharset = NS_ConvertUCS2toUTF8(value).ToNewCString();              nsMemory::Free(value);            }          }          if (!text->defaultCharset)            text->defaultCharset = nsCRT::strdup("");          text->charset = nsCRT::strdup("");        }      }    }  }    return ((MimeObjectClass*)&MIME_SUPERCLASS)->initialize(obj);}