str.Assign(NS_LITERAL_CSTRING("UTF-16"));
str.AssignLiteral("UTF-16");
void GetHTMLCharset(guchar * data, PRInt32 dataLength, nsCString& 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((const char *)data, dataLength);    nsACString::const_iterator start, end;    htmlStr.BeginReading(start);    htmlStr.EndReading(end);    nsACString::const_iterator valueStart(start), valueEnd(start);    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 (FindCharInReadable('"', start, end))                valueEnd = start;        }    }    // find "charset" in HTML    if (valueStart != valueEnd) {        str = Substring(valueStart, valueEnd);        ToUpperCase(str);#ifdef DEBUG_CLIPBOARD        printf("Charset of HTML = %s\n", charsetUpperStr.get());#endif        return;    }    str.Assign(NS_LITERAL_CSTRING("UNKNOWN"));}