aForm->GetDocument(*getter_AddRefs(doc));
aForm->GetDocument(getter_AddRefs(doc));
nsFormSubmission::GetSubmitCharset(nsIHTMLContent* aForm,                                   PRUint8 aCtrlsModAtSubmit,                                   nsACString& oCharset){  oCharset = NS_LITERAL_CSTRING("UTF-8"); // default to utf-8  nsresult rv = NS_OK;  nsAutoString acceptCharsetValue;  nsHTMLValue value;  rv = aForm->GetHTMLAttribute(nsHTMLAtoms::acceptcharset, value);  if (rv == NS_CONTENT_ATTR_HAS_VALUE && value.GetUnit() == eHTMLUnit_String) {    value.GetStringValue(acceptCharsetValue);  }  PRInt32 charsetLen = acceptCharsetValue.Length();  if (charsetLen > 0) {    PRInt32 offset=0;    PRInt32 spPos=0;    // get charset from charsets one by one    nsCOMPtr<nsICharsetAlias> calias(do_GetService(kCharsetAliasCID, &rv));    if (NS_FAILED(rv)) {      return;    }    if (calias) {      do {        spPos = acceptCharsetValue.FindChar(PRUnichar(' '), offset);        PRInt32 cnt = ((-1==spPos)?(charsetLen-offset):(spPos-offset));        if (cnt > 0) {          nsAutoString uCharset;          acceptCharsetValue.Mid(uCharset, offset, cnt);          nsCAutoString charset; charset.AssignWithConversion(uCharset);          if (NS_SUCCEEDED(calias->GetPreferred(charset, oCharset)))            return;        }        offset = spPos + 1;      } while (spPos != -1);    }  }  // if there are no accept-charset or all the charset are not supported  // Get the charset from document  nsCOMPtr<nsIDocument> doc;  aForm->GetDocument(*getter_AddRefs(doc));  if (doc) {    nsAutoString docCharset;    rv = doc->GetDocumentCharacterSet(docCharset);    if (NS_SUCCEEDED(rv))      CopyUCS2toASCII(docCharset, oCharset);  }  if (aCtrlsModAtSubmit==IBMBIDI_CONTROLSTEXTMODE_VISUAL     && oCharset.Equals(NS_LITERAL_CSTRING("windows-1256"),                        nsCaseInsensitiveCStringComparator())) {//Mohamed    oCharset = NS_LITERAL_CSTRING("IBM864");  }  else if (aCtrlsModAtSubmit==IBMBIDI_CONTROLSTEXTMODE_LOGICAL          && oCharset.Equals(NS_LITERAL_CSTRING("IBM864"),                             nsCaseInsensitiveCStringComparator())) {    oCharset = NS_LITERAL_CSTRING("IBM864i");  }  else if (aCtrlsModAtSubmit==IBMBIDI_CONTROLSTEXTMODE_VISUAL          && oCharset.Equals(NS_LITERAL_CSTRING("ISO-8859-6"),                             nsCaseInsensitiveCStringComparator())) {    oCharset = NS_LITERAL_CSTRING("IBM864");  }  else if (aCtrlsModAtSubmit==IBMBIDI_CONTROLSTEXTMODE_VISUAL          && oCharset.Equals(NS_LITERAL_CSTRING("UTF-8"),                             nsCaseInsensitiveCStringComparator())) {    oCharset = NS_LITERAL_CSTRING("IBM864");  }}