From 6b54fa0505da819078b523cc41e158f8125e5603 Mon Sep 17 00:00:00 2001 From: "nhotta%netscape.com" Date: Tue, 6 Apr 1999 21:46:15 +0000 Subject: [PATCH] Changed to use unicode converter and related changes. --- mailnews/compose/src/msgCompGlue.cpp | 10 +++++- mailnews/compose/src/nsComposeAppCore.cpp | 44 +++++++++++++++++------ 2 files changed, 42 insertions(+), 12 deletions(-) diff --git a/mailnews/compose/src/msgCompGlue.cpp b/mailnews/compose/src/msgCompGlue.cpp index 549f77b6ff1..79e862e0563 100644 --- a/mailnews/compose/src/msgCompGlue.cpp +++ b/mailnews/compose/src/msgCompGlue.cpp @@ -127,9 +127,17 @@ nsresult ConvertToUnicode(const nsString aCharset, nsIUnicodeDecoder* decoder = nsnull; PRUnichar *unichars; PRInt32 unicharLength; + nsString convCharset; + // map to converter charset + if (aCharset.EqualsIgnoreCase("us-ascii")) { + convCharset.SetString("iso-8859-1"); + } + else { + convCharset = aCharset; + } // get an unicode converter - res = ccm->GetUnicodeDecoder(&aCharset, &decoder); + res = ccm->GetUnicodeDecoder(&convCharset, &decoder); if(NS_SUCCEEDED(res) && (nsnull != decoder)) { PRInt32 srcLen = PL_strlen(inCString); res = decoder->Length(inCString, 0, srcLen, &unicharLength); diff --git a/mailnews/compose/src/nsComposeAppCore.cpp b/mailnews/compose/src/nsComposeAppCore.cpp index 51aa9b7b818..4980947035d 100644 --- a/mailnews/compose/src/nsComposeAppCore.cpp +++ b/mailnews/compose/src/nsComposeAppCore.cpp @@ -85,6 +85,9 @@ extern char * INTL_GetDefaultMailCharset(void); extern nsresult ConvertFromUnicode(const nsString aCharset, const nsString inString, char** outCString); +extern nsresult ConvertToUnicode(const nsString aCharset, + const char *inCString, + nsString &outString); extern const char *msgCompHeaderInternalCharset(void); // we need this because of an egcs 1.0 (and possibly gcc) compiler bug @@ -226,17 +229,36 @@ nsComposeAppCore::ConstructAfterJavaScript(nsIWebShell *aWebShell) if (mMsgCompFields && domDoc) { - char *aString; - mMsgCompFields->GetTo(&aString); - nsString to = aString; - mMsgCompFields->GetCc(&aString); - nsString cc = aString; - mMsgCompFields->GetBcc(&aString); - nsString bcc = aString; - mMsgCompFields->GetSubject(&aString); - nsString subject = aString; - mMsgCompFields->GetBody(&aString); - nsString body = aString; + nsString aCharset(msgCompHeaderInternalCharset()); + char *aString; + nsString to, cc, bcc, subject, body; + nsresult res; + + mMsgCompFields->GetTo(&aString); + if (NS_FAILED(res = ConvertToUnicode(aCharset, aString, to))) { + to = aString; + } + mMsgCompFields->GetCc(&aString); + if (NS_FAILED(res = ConvertToUnicode(aCharset, aString, cc))) { + cc = aString; + } + mMsgCompFields->GetBcc(&aString); + if (NS_FAILED(res = ConvertToUnicode(aCharset, aString, bcc))) { + bcc = aString; + } + mMsgCompFields->GetSubject(&aString); + if (NS_FAILED(res = ConvertToUnicode(aCharset, aString, subject))) { + to = subject; + } + + // mail charset is used for the body instead of utf-8 + char *mail_charset; + mMsgCompFields->GetCharacterSet(&mail_charset); + aCharset.SetString(mail_charset); + mMsgCompFields->GetBody(&aString); + if (NS_FAILED(res = ConvertToUnicode(aCharset, aString, body))) { + body = subject; + } SetWindowFields(domDoc, to, cc, bcc, subject, body); }