diff --git a/mozilla/mailnews/compose/src/msgCompGlue.cpp b/mozilla/mailnews/compose/src/msgCompGlue.cpp index 59f6759841d..11a5afb2e85 100644 --- a/mozilla/mailnews/compose/src/msgCompGlue.cpp +++ b/mozilla/mailnews/compose/src/msgCompGlue.cpp @@ -228,6 +228,33 @@ PRBool INTL_stateful_charset(const char *charset) return (PL_strcasecmp(charset, "iso-2022-jp") == 0); } +// Check 7bit in a given buffer. +// This is expensive (both memory and performance). +// The check would be very simple if applied to an unicode text (e.g. nsString or utf-8). +// Possible optimazaion is to search ESC(0x1B) in case of iso-2022-jp and iso-2022-kr. +PRBool INTL_7bit_data_part(const char *charset, const char *inString, const PRUint32 size) +{ + char *aCString; + nsString aCharset(charset); + nsString outString; + nsresult res; + + aCString = (char *) PR_Malloc(size + 1); + if (nsnull != aCString) { + PL_strncpy(aCString, inString, size); // make a C string + res = ConvertToUnicode(aCharset, aCString, outString); + PR_Free(aCString); + if (NS_SUCCEEDED(res)) { + for (PRInt32 i = 0; i < outString.Length(); i++) { + if (outString[i] > 127) { + return PR_FALSE; + } + } + } + } + return PR_TRUE; // all 7 bit +} + // Obsolescent int INTL_IsLeadByte(int charSetID,unsigned char ch) {return 0;} // Obsolescent diff --git a/mozilla/mailnews/compose/src/nsComposeAppCore.cpp b/mozilla/mailnews/compose/src/nsComposeAppCore.cpp index 23e65f99636..026dbb3114d 100644 --- a/mozilla/mailnews/compose/src/nsComposeAppCore.cpp +++ b/mozilla/mailnews/compose/src/nsComposeAppCore.cpp @@ -304,6 +304,8 @@ nsresult nsComposeAppCore::SetDocumentCharset(class nsString const & aCharset) NS_RELEASE(domDoc); } } + // Set charset, this will be used for the MIME charset labeling. + mMsgCompFields->SetCharacterSet(nsAutoCString(aCharset), NULL); return res; } @@ -646,6 +648,10 @@ nsComposeAppCore::NewMessage(nsAutoString& aUrl, this, // callbacks 615, // width 650); // height + + // Get the default charset from pref, use this as a mail charset. + // TODO: For reply/forward, original charset need to be used instead. + mMsgCompFields->SetCharacterSet(INTL_GetDefaultMailCharset(), NULL); if (tree && nodeList && msgAppCore) { nsCOMPtr object; @@ -752,11 +758,6 @@ NS_IMETHODIMP nsComposeAppCore::SendMessage(nsAutoString& aAddrTo, // nsIMsgCompose *pMsgCompose; if (mMsgCompFields) { - // Get the default charset from pref, use this as a mail charset for now. - // TODO: For reply/forward, original charset need to be used instead. - // TODO: Also need to update charset for the charset menu. - mMsgCompFields->SetCharacterSet(INTL_GetDefaultMailCharset(), NULL); - nsString aString; nsString aCharset(msgCompHeaderInternalCharset()); char *outCString;