Changes for charset menu and 7bit data check.

git-svn-id: svn://10.0.0.236/trunk@27901 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
nhotta%netscape.com
1999-04-16 20:43:14 +00:00
parent 71c297c6d4
commit ad7c6f4185
2 changed files with 33 additions and 5 deletions

View File

@@ -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

View File

@@ -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<nsISupports> 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;