void nsEudoraCompose::ExtractCharset( nsString& str) { nsString tStr; PRInt32 idx = str.Find( "charset=", PR_TRUE); if (idx != -1) { idx += 8; str.Right( tStr, str.Length() - idx); idx = tStr.FindChar( ';'); if (idx != -1) tStr.Left( str, idx); else str = tStr; str.Trim( kWhitespace); if ((str.CharAt( 0) == '"') && (str.Length() > 2)) { str.Mid( tStr, 1, str.Length() - 2); str = tStr; str.Trim( kWhitespace); } } else str.Truncate(); }
nsresult nsRDFParserUtils::GetQuotedAttributeValue(const nsString& aSource, const nsString& aAttribute, nsString& aValue) { static const char kQuote = '\"'; static const char kApostrophe = '\''; PRInt32 offset; PRInt32 endOffset = -1; nsresult result = NS_OK; offset = aSource.Find(aAttribute, 0); if (-1 != offset) { offset = aSource.FindChar('=', offset); PRUnichar next = aSource.CharAt(++offset); if (kQuote == next) { endOffset = aSource.FindChar(kQuote, ++offset); } else if (kApostrophe == next) { endOffset = aSource.FindChar(kApostrophe, ++offset); } if (-1 != endOffset) { aSource.Mid(aValue, offset, endOffset-offset); } else { // Mismatched quotes - return an error result = NS_ERROR_FAILURE; } } else { aValue.Truncate(); } return result; }
void nsEudoraCompose::ExtractType( nsString& str) { nsString tStr; PRInt32 idx = str.FindChar( ';'); if (idx != -1) { str.Left( tStr, idx); str = tStr; } str.Trim( kWhitespace); if ((str.CharAt( 0) == '"') && (str.Length() > 2)) { str.Mid( tStr, 1, str.Length() - 2); str = tStr; str.Trim( kWhitespace); } // if multipart then ignore it since no outlook message body is ever // valid multipart! if (str.Length() > 10) { str.Left( tStr, 10); if (tStr.LowerCaseEqualsLiteral("multipart/")) str.Truncate(); } }