aStyleSheetData.Mid(str,sizeof(atCharsetStr),-1);
aStyleSheetData.Mid(str,sizeof(atCharsetStr)-1,-1);
nsresult CSSLoaderImpl::SetCharset(/*in*/ const nsString &aHTTPHeader,                                    /*in*/ const nsString &aStyleSheetData)  // sets the charset based upon the data passed in  //  - if HTTPHeader is not empty and it has a charset, use that  //  - otherwise, if the StyleSheetData is not empty and it has '@charset' as the first substring,  //    then use that  //  - othersise set the default charset{  nsresult rv = NS_OK;  nsString str;  PRBool setCharset = PR_FALSE;  if (aHTTPHeader.Length() > 0) {    // check if it has the charset= parameter    PRInt32 charsetOffset;    static const char* charsetStr = "charset=";    if ((charsetOffset = aHTTPHeader.Find(charsetStr,PR_TRUE)) > 0) {      aHTTPHeader.Mid(str, charsetOffset + sizeof(charsetStr), -1);      setCharset = PR_TRUE;    }  } else if (aStyleSheetData.Length() > 0) {    static const char* atCharsetStr = "@charset";    if (aStyleSheetData.Find(atCharsetStr) > -1) {      nsString strValue;      // skip past the ident      aStyleSheetData.Mid(str,sizeof(atCharsetStr),-1);      // strip any whitespace      str.StripWhitespace();      // truncate everything past the delimiter (semicolon)      PRInt32 pos = str.Find(";");      if (pos > -1) {        str.Left(strValue,pos);      }      // strip any quotes      strValue.Trim("\"\'");      // that's the charset!      str = strValue;      setCharset = PR_TRUE;    }  }  if (PR_TRUE == setCharset) {    rv = SetCharset(str);  }  return rv;}