fix 16808. change hard coded utf-8'to UTF-8', get charset hint from webshell. r=nhotta

git-svn-id: svn://10.0.0.236/trunk@53070 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
ftang%netscape.com
1999-11-10 05:50:10 +00:00
parent 50c4711b2e
commit f274743ebb
2 changed files with 38 additions and 8 deletions

View File

@@ -206,7 +206,7 @@ nsXMLDocument::StartDocumentLoad(const char* aCommand,
}
nsIWebShell* webShell;
nsAutoString charset("utf-8");
nsAutoString charset("UTF-8");
nsCharsetSource charsetSource = kCharsetFromDocTypeDefault;
nsCOMPtr<nsIURI> aUrl;
@@ -261,9 +261,24 @@ nsXMLDocument::StartDocumentLoad(const char* aCommand,
if (NS_OK == rv) {
nsIXMLContentSink* sink;
aContainer->QueryInterface(kIWebShellIID, (void**)&webShell);
rv = NS_NewXMLContentSink(&sink, this, aUrl, webShell);
NS_IF_RELEASE(webShell);
rv = aContainer->QueryInterface(kIWebShellIID, (void**)&webShell);
if(NS_SUCCEEDED(rv) && (nsnull != webShell)) {
if(0 == nsCRT::strcmp("view-source", aCommand)) { // only do this for view-source
const PRUnichar* hintCharset = nsnull;
nsCharsetSource hintSource = kCharsetUninitialized;
rv = webShell->GetCharacterSetHint(&hintCharset, &hintSource);
if(NS_SUCCEEDED(rv)) {
if(hintSource > charsetSource) {
charset = hintCharset;
charsetSource = hintSource;
}
}
}
if(NS_SUCCEEDED(rv))
rv = NS_NewXMLContentSink(&sink, this, aUrl, webShell);
NS_IF_RELEASE(webShell);
}
if (NS_OK == rv) {
// Set the parser as the stream listener for the document loader...