if (!nsCRT::strcasecmp(cset, "us-ascii")) SetMailCharacterSetToMsgWindow(obj, NS_LITERAL_STRING("ISO-8859-1")); else SetMailCharacterSetToMsgWindow(obj, NS_ConvertASCIItoUCS2(cset));
if (!(obj->options->override_charset)) {  if (!nsCRT::strcasecmp(cset, "us-ascii")) SetMailCharacterSetToMsgWindow(obj, NS_LITERAL_STRING("ISO-8859-1")); else SetMailCharacterSetToMsgWindow(obj, NS_ConvertASCIItoUCS2(cset)); }
MimeMultipart_parse_line (char *line, PRInt32 length, MimeObject *obj){  MimeMultipart *mult = (MimeMultipart *) obj;  int status = 0;  MimeMultipartBoundaryType boundary;  PR_ASSERT(line && *line);  if (!line || !*line) return -1;  PR_ASSERT(!obj->closed_p);  if (obj->closed_p) return -1;  /* If we're supposed to write this object, but aren't supposed to convert	 it to HTML, simply pass it through unaltered. */  if (obj->output_p &&	  obj->options &&	  !obj->options->write_html_p &&	  obj->options->output_fn)	return MimeObject_write(obj, line, length, PR_TRUE);  if (mult->state == MimeMultipartEpilogue)  /* already done */	boundary = MimeMultipartBoundaryTypeNone;  else	boundary = ((MimeMultipartClass *)obj->clazz)->check_boundary(obj, line,																  length);  if (boundary == MimeMultipartBoundaryTypeTerminator ||	  boundary == MimeMultipartBoundaryTypeSeparator)	{	  /* Match!  Close the currently-open part, move on to the next		 state, and discard this line.	   */	  if (mult->state != MimeMultipartPreamble)		status = ((MimeMultipartClass *)obj->clazz)->close_child(obj);	  if (status < 0) return status;	  if (boundary == MimeMultipartBoundaryTypeTerminator)		mult->state = MimeMultipartEpilogue;	  else		{		  mult->state = MimeMultipartHeaders;		  /* Reset the header parser for this upcoming part. */		  PR_ASSERT(!mult->hdrs);		  if (mult->hdrs)			MimeHeaders_free(mult->hdrs);		  mult->hdrs = MimeHeaders_new();		  if (!mult->hdrs)			return MIME_OUT_OF_MEMORY;		}	  /* Now return, to ignore the boundary line itself. */	  return 0;	}  /* Otherwise, this isn't a boundary string.  So do whatever it is we	 should do with this line (parse it as a header, feed it to the	 child part, ignore it, etc.) */  switch (mult->state)	{	case MimeMultipartPreamble:	case MimeMultipartEpilogue:	  /* Ignore this line. */	  break;	case MimeMultipartHeaders:    /* Parse this line as a header for the sub-part. */    {      status = MimeHeaders_parse_line(line, length, mult->hdrs);      if (status < 0) return status;            // If this line is blank, we're now done parsing headers, and should      // now examine the content-type to create this "body" part.      //      if (*line == CR || *line == LF)      {        status = ((MimeMultipartClass *) obj->clazz)->create_child(obj);        if (status < 0) return status;        PR_ASSERT(mult->state != MimeMultipartHeaders);        // Ok, at this point, we need to examine the headers and see if there        // is a special charset (i.e. non US-ASCII) for this message. If so,         // we need to tell the emitter that this is the case for use in in any        // possible reply or forward operation.        //        PRBool isAlternativeOrRelated;        PRBool isBody = MimeObjectChildIsMessageBody(obj, &isAlternativeOrRelated);        if (isBody)        {      	  MimeContainer *container = (MimeContainer*) obj;          // If we have only one child and this is the message body object,          // this we should check for a special charset and notify the emitter           // if one exists!      	  if ( (container->children) && (container->nchildren == 1) && (obj->options) )          {            char *ct = MimeHeaders_get(mult->hdrs, HEADER_CONTENT_TYPE, PR_FALSE, PR_FALSE);            if (ct)            {              char *cset = MimeHeaders_get_parameter (ct, "charset", NULL, NULL);              if (cset)              {                mimeEmitterUpdateCharacterSet(obj->options, cset);                // Also set this charset to msgWindow                if (!nsCRT::strcasecmp(cset, "us-ascii"))                  SetMailCharacterSetToMsgWindow(obj, NS_LITERAL_STRING("ISO-8859-1"));                else                  SetMailCharacterSetToMsgWindow(obj, NS_ConvertASCIItoUCS2(cset));              }              PR_FREEIF(ct);              PR_FREEIF(cset);            }          }         }      }      break;    }	case MimeMultipartPartFirstLine:	  /* Hand this line off to the sub-part. */	  status = (((MimeMultipartClass *) obj->clazz)->parse_child_line(obj,																	  line,																	  length,																	  PR_TRUE));	  if (status < 0) return status;	  mult->state = MimeMultipartPartLine;	  break;	case MimeMultipartPartLine:	  /* Hand this line off to the sub-part. */	  status = (((MimeMultipartClass *) obj->clazz)->parse_child_line(obj,																	  line,																	  length,																	  PR_FALSE));	  if (status < 0) return status;	  break;	default:	  PR_ASSERT(0);	  return -1;	}  return 0;}