From de4dad295b9fefb02c8191df99053d85d35a8442 Mon Sep 17 00:00:00 2001 From: "nhotta%netscape.com" Date: Mon, 1 May 2000 22:00:46 +0000 Subject: [PATCH] Changed to use canonical charset name instead of using the charset name from the message header as is, bug 37562. --- mailnews/compose/src/nsMsgCompose.cpp | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/mailnews/compose/src/nsMsgCompose.cpp b/mailnews/compose/src/nsMsgCompose.cpp index e0e6786c42c..7935a2b2a40 100644 --- a/mailnews/compose/src/nsMsgCompose.cpp +++ b/mailnews/compose/src/nsMsgCompose.cpp @@ -31,6 +31,7 @@ #include "nsIDOMNamedNodeMap.h" #include "nsMsgI18N.h" #include "nsICharsetConverterManager.h" +#include "nsICharsetConverterManager2.h" #include "nsMsgCompCID.h" #include "nsMsgSend.h" #include "nsIMessenger.h" //temporary! @@ -1389,9 +1390,27 @@ NS_IMETHODIMP QuotingOutputStreamListener::OnStopRequest(nsIChannel *aChannel, n // Re-label "us-ascii" to "ISO-8859-1" since the original body may contain // non us-ascii characters with eitity encoded. - nsAutoString aCharset; aCharset.AssignWithConversion(ptr); + aCharset.AssignWithConversion(ptr); if (aCharset.EqualsIgnoreCase("us-ascii")) aCharset.AssignWithConversion("ISO-8859-1"); + else { + // Use canonical charset name instead of using the charset name from the message header as is. + // This is needed for charset menu item to have a check mark correctly, for example. + nsCOMPtr ccm2 = do_GetService(kCharsetConverterManagerCID, &rv); + if (NS_SUCCEEDED(rv)) { + nsCOMPtr charsetAtom; + rv = ccm2->GetCharsetAtom(aCharset.GetUnicode(), getter_AddRefs(charsetAtom)); + if (NS_SUCCEEDED(rv)) { + nsAutoString canonicalCharset; + rv = charsetAtom->ToString(canonicalCharset); + if (NS_SUCCEEDED(rv)) + aCharset = canonicalCharset; + else + rv = NS_OK; // no cannonical charset name does not mean an error + } + } + } + compFields->SetCharacterSet(aCharset.GetUnicode()); }