str.Assign(NS_LITERAL_CSTRING("OLD-MOZILLA"));
str.AssignLiteral("OLD-MOZILLA");
void GetHTMLCharset(char* data, PRInt32 dataLength, nsACString& str){  // if detect "FFFE" or "FEFF", assume utf-16  PRUnichar* beginChar =  (PRUnichar*)data;  if ((beginChar[0] == 0xFFFE) || (beginChar[0] == 0xFEFF)) {    str.Assign(NS_LITERAL_CSTRING("UTF-16"));    return;  }  // no "FFFE" and "FEFF", assume ASCII first to find "charset" info  nsDependentCString htmlStr = nsDependentCString(data, dataLength);  nsACString::const_iterator start, end, valueStart, valueEnd;  htmlStr.BeginReading(start);  htmlStr.EndReading(end);  htmlStr.BeginReading(valueStart);  htmlStr.BeginReading(valueEnd);    if (CaseInsensitiveFindInReadable(NS_LITERAL_CSTRING("CONTENT=\"text/html;"),                                    start, end)) {    start = end;    htmlStr.EndReading(end);    if (CaseInsensitiveFindInReadable(NS_LITERAL_CSTRING("charset="),                                      start, end)) {      valueStart = end;      start = end;      htmlStr.EndReading(end);                if (CaseInsensitiveFindInReadable(NS_LITERAL_CSTRING("\""), start, end))        valueEnd = start;    }  }  // find "charset" in HTML  if (valueStart != valueEnd) {    const nsACString & charsetStr = Substring(valueStart, valueEnd);    if ( !charsetStr.IsEmpty() ) {      nsCString charsetUpperStr;      ToUpperCase(charsetStr, charsetUpperStr);#ifdef DEBUG_CLIPBOARD      printf("Charset of HTML = %s\n", charsetUpperStr.get());#endif      str.Assign(charsetUpperStr);      return;    }  }  // no "charset" info, assume data come from old-version mozilla  // [UCS2 encoding (without "FFFE" or "FEFF" at the beginning)]  //  // TODO: it may also be "text/html" without "charset".  // can't distinguish between them. Sochoose OLD-MOZILLA here to  // make compitable with old-version mozilla  str.Assign(NS_LITERAL_CSTRING("OLD-MOZILLA"));}