diff --git a/extensions/transformiix/source/base/txURIUtils.cpp b/extensions/transformiix/source/base/txURIUtils.cpp index 912215d37980..81eeea6b9ab7 100644 --- a/extensions/transformiix/source/base/txURIUtils.cpp +++ b/extensions/transformiix/source/base/txURIUtils.cpp @@ -349,6 +349,10 @@ URIUtils::ResetWithSource(nsIDocument *aNewDoc, nsIDOMNode *aSourceNode) aNewDoc->Reset(channel, loadGroup); aNewDoc->SetBaseURL(sourceDoc->GetBaseURL()); + // Copy charset + aNewDoc->SetDocumentCharacterSet(sourceDoc->GetDocumentCharacterSet()); + aNewDoc->SetDocumentCharacterSetSource( + sourceDoc->GetDocumentCharacterSetSource()); } #endif /* TX_EXE */ diff --git a/extensions/transformiix/source/xslt/txMozillaTextOutput.cpp b/extensions/transformiix/source/xslt/txMozillaTextOutput.cpp index 8e3780aaa8cd..d02cf99753cf 100644 --- a/extensions/transformiix/source/xslt/txMozillaTextOutput.cpp +++ b/extensions/transformiix/source/xslt/txMozillaTextOutput.cpp @@ -48,6 +48,7 @@ #include "nsIDocumentTransformer.h" #include "nsNetUtil.h" #include "nsIDOMNSDocument.h" +#include "nsIParser.h" static NS_DEFINE_CID(kXMLDocumentCID, NS_XMLDOCUMENT_CID); @@ -182,6 +183,18 @@ void txMozillaTextOutput::createResultDocument(nsIDOMDocument* aSourceDocument, doc->Reset(channel, loadGroup); doc->SetBaseURL(sourceDoc->GetBaseURL()); + // Set the charset + if (!mOutputFormat.mEncoding.IsEmpty()) { + doc->SetDocumentCharacterSet( + NS_LossyConvertUTF16toASCII(mOutputFormat.mEncoding)); + doc->SetDocumentCharacterSetSource(kCharsetFromOtherComponent); + } + else { + doc->SetDocumentCharacterSet(sourceDoc->GetDocumentCharacterSet()); + doc->SetDocumentCharacterSetSource( + sourceDoc->GetDocumentCharacterSetSource()); + } + // Notify the contentsink that the document is created nsCOMPtr observer = do_QueryReferent(mObserver); if (observer) { diff --git a/extensions/transformiix/source/xslt/txMozillaXMLOutput.cpp b/extensions/transformiix/source/xslt/txMozillaXMLOutput.cpp index f13438992d8a..4474955c8a26 100644 --- a/extensions/transformiix/source/xslt/txMozillaXMLOutput.cpp +++ b/extensions/transformiix/source/xslt/txMozillaXMLOutput.cpp @@ -725,6 +725,13 @@ txMozillaXMLOutput::createResultDocument(const nsAString& aName, PRInt32 aNsID, // Reset and set up the document URIUtils::ResetWithSource(doc, aSourceDocument); + // Set the charset + if (!mOutputFormat.mEncoding.IsEmpty()) { + doc->SetDocumentCharacterSet( + NS_LossyConvertUTF16toASCII(mOutputFormat.mEncoding)); + doc->SetDocumentCharacterSetSource(kCharsetFromOtherComponent); + } + // Set the mime-type if (!mOutputFormat.mMediaType.IsEmpty()) { doc->SetContentType(mOutputFormat.mMediaType);