Use a better sourcelevel when setting charset through xsl:output element. Also make sure to use the proper form when setting the charset.

r/sr=bz
This commit is contained in:
cvshook%sicking.cc 2005-02-05 13:47:43 +00:00
Родитель ef83c8a4f6
Коммит 403f464793
3 изменённых файлов: 26 добавлений и 9 удалений

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

@ -49,6 +49,7 @@
#include "nsNetUtil.h"
#include "nsIDOMNSDocument.h"
#include "nsIParser.h"
#include "nsICharsetAlias.h"
static NS_DEFINE_CID(kXMLDocumentCID, NS_XMLDOCUMENT_CID);
@ -187,9 +188,16 @@ void txMozillaTextOutput::createResultDocument(nsIDOMDocument* aSourceDocument,
// Set the charset
if (!mOutputFormat.mEncoding.IsEmpty()) {
doc->SetDocumentCharacterSet(
NS_LossyConvertUTF16toASCII(mOutputFormat.mEncoding));
doc->SetDocumentCharacterSetSource(kCharsetFromOtherComponent);
NS_LossyConvertUTF16toASCII charset(mOutputFormat.mEncoding);
nsCAutoString canonicalCharset;
nsCOMPtr<nsICharsetAlias> calias =
do_GetService("@mozilla.org/intl/charsetalias;1");
if (calias &&
NS_SUCCEEDED(calias->GetPreferred(charset, canonicalCharset))) {
doc->SetDocumentCharacterSet(canonicalCharset);
doc->SetDocumentCharacterSetSource(kCharsetFromOtherComponent);
}
}
else {
doc->SetDocumentCharacterSet(sourceDoc->GetDocumentCharacterSet());

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

@ -71,6 +71,7 @@
#include "nsIStyleSheetLinkingElement.h"
#include "nsIDocumentTransformer.h"
#include "nsICSSLoader.h"
#include "nsICharsetAlias.h"
extern nsINameSpaceManager* gTxNameSpaceManager;
@ -738,9 +739,16 @@ txMozillaXMLOutput::createResultDocument(const nsAString& aName, PRInt32 aNsID,
// Set the charset
if (!mOutputFormat.mEncoding.IsEmpty()) {
doc->SetDocumentCharacterSet(
NS_LossyConvertUTF16toASCII(mOutputFormat.mEncoding));
doc->SetDocumentCharacterSetSource(kCharsetFromOtherComponent);
NS_LossyConvertUTF16toASCII charset(mOutputFormat.mEncoding);
nsCAutoString canonicalCharset;
nsCOMPtr<nsICharsetAlias> calias =
do_GetService("@mozilla.org/intl/charsetalias;1");
if (calias &&
NS_SUCCEEDED(calias->GetPreferred(charset, canonicalCharset))) {
doc->SetDocumentCharacterSet(canonicalCharset);
doc->SetDocumentCharacterSetSource(kCharsetFromOtherComponent);
}
}
// Set the mime-type

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

@ -108,9 +108,10 @@ enum eParserDocType {
#define kCharsetFromMetaTag 9
#define kCharsetFromByteOrderMark 10
#define kCharsetFromChannel 11
#define kCharsetFromParentForced 12
#define kCharsetFromUserForced 13
#define kCharsetFromOtherComponent 14
#define kCharsetFromOtherComponent 12
// Levels below here will be forced onto childframes too
#define kCharsetFromParentForced 13
#define kCharsetFromUserForced 14
#define kCharsetFromPreviousLoading 15
enum eStreamState {eNone,eOnStart,eOnDataAvail,eOnStop};