This commit is contained in:
nhotta%netscape.com 1999-05-04 22:28:17 +00:00
Родитель 0ea06142bc
Коммит 2cad0a7014
2 изменённых файлов: 14 добавлений и 24 удалений

Просмотреть файл

@ -141,7 +141,9 @@ nsresult ConvertFromUnicode(const nsString aCharset,
*outCString = (char *) PR_Malloc(dstLength + 1); *outCString = (char *) PR_Malloc(dstLength + 1);
if (*outCString != nsnull) { if (*outCString != nsnull) {
res = encoder->Convert(unichars, &unicharLength, *outCString, &dstLength); res = encoder->Convert(unichars, &unicharLength, *outCString, &dstLength);
NS_ASSERTION(unicharLength == originalLength, "unicharLength != originalLength"); // This may also happen for the case like requesting charset "ISO-8859-1" for text in CJK range.
// We don't want assertion for those cases.
// NS_ASSERTION(unicharLength == originalLength, "unicharLength != originalLength");
} }
} }
if (*outCString != nsnull) { if (*outCString != nsnull) {
@ -189,6 +191,7 @@ nsresult ConvertToUnicode(const nsString aCharset,
// convert to unicode // convert to unicode
res = decoder->Convert(unichars, 0, &unicharLength, inCString, 0, &srcLen); res = decoder->Convert(unichars, 0, &unicharLength, inCString, 0, &srcLen);
outString.SetString(unichars, unicharLength); outString.SetString(unichars, unicharLength);
PR_Free(unichars);
} }
else { else {
res = NS_ERROR_OUT_OF_MEMORY; res = NS_ERROR_OUT_OF_MEMORY;
@ -257,7 +260,7 @@ char * INTL_GetDefaultMailCharset()
retVal = PL_strdup(prefValue); retVal = PL_strdup(prefValue);
} }
else else
retVal = PL_strdup("us-ascii"); retVal = PL_strdup("us-ascii");
} }
return (nsnull != retVal) ? retVal : PL_strdup("us-ascii"); return (nsnull != retVal) ? retVal : PL_strdup("us-ascii");
@ -274,6 +277,7 @@ PRBool INTL_stateful_charset(const char *charset)
// This is expensive (both memory and performance). // 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). // 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. // Possible optimazaion is to search ESC(0x1B) in case of iso-2022-jp and iso-2022-kr.
// Or convert and check line by line.
PRBool INTL_7bit_data_part(const char *charset, const char *inString, const PRUint32 size) PRBool INTL_7bit_data_part(const char *charset, const char *inString, const PRUint32 size)
{ {
char *aCString; char *aCString;

Просмотреть файл

@ -333,28 +333,10 @@ nsComposeAppCore::ConstructAfterJavaScript(nsIWebShell *aWebShell)
nsresult nsComposeAppCore::SetDocumentCharset(class nsString const & aCharset) nsresult nsComposeAppCore::SetDocumentCharset(class nsString const & aCharset)
{ {
nsresult res = NS_OK;
if (nsnull != mWindow)
{
nsIDOMDocument* domDoc;
res = mWindow->GetDocument(&domDoc);
if (NS_SUCCEEDED(res) && nsnull != domDoc)
{
nsIDocument * doc;
res = domDoc->QueryInterface(kIDocumentIID,(void**)&doc);
if (NS_SUCCEEDED(res) && nsnull != doc)
{
doc->SetDocumentCharacterSet(aCharset);
NS_RELEASE(doc);
}
NS_RELEASE(domDoc);
}
}
// Set charset, this will be used for the MIME charset labeling. // Set charset, this will be used for the MIME charset labeling.
mMsgCompFields->SetCharacterSet(nsAutoCString(aCharset), NULL); mMsgCompFields->SetCharacterSet(nsAutoCString(aCharset), NULL);
return res; return NS_OK;
} }
nsIScriptContext * nsIScriptContext *
@ -635,6 +617,7 @@ nsComposeAppCore::NewMessage(nsAutoString& aUrl,
{ {
nsresult rv; nsresult rv;
nsString controllerCID; nsString controllerCID;
char *default_mail_charset = nsnull;
mArgs = args; mArgs = args;
NS_WITH_SERVICE(nsIAppShellService, appShell, kAppShellServiceCID, &rv); NS_WITH_SERVICE(nsIAppShellService, appShell, kAppShellServiceCID, &rv);
@ -661,9 +644,12 @@ nsComposeAppCore::NewMessage(nsAutoString& aUrl,
615, // width 615, // width
650); // height 650); // height
// Get the default charset from pref, use this as a mail charset. // Get the default charset from pref, use this as a mail charset.
// TODO: For reply/forward, original charset need to be used instead. default_mail_charset = INTL_GetDefaultMailCharset();
mMsgCompFields->SetCharacterSet(INTL_GetDefaultMailCharset(), NULL); if (NULL != default_mail_charset) {
mMsgCompFields->SetCharacterSet(default_mail_charset, NULL);
PR_Free(default_mail_charset);
}
if (tree && nodeList && msgAppCore) { if (tree && nodeList && msgAppCore) {
nsCOMPtr<nsISupports> object; nsCOMPtr<nsISupports> object;