1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 #include "nsISupportsImpl.h"
7 #include "mozilla/Encoding.h"
9 const mozilla::Encoding
* nsHtml5MetaScanner::sniff(nsHtml5ByteReadable
* bytes
) {
16 bool nsHtml5MetaScanner::tryCharset(nsHtml5String charset
) {
17 // This code needs to stay in sync with
18 // nsHtml5StreamParser::internalEncodingDeclaration. Unfortunately, the
19 // trickery with member fields here leads to some copy-paste reuse. :-(
21 nsString charset16
; // Not Auto, because using it to hold nsStringBuffer*
22 charset
.ToString(charset16
);
23 CopyUTF16toUTF8(charset16
, label
);
24 const mozilla::Encoding
* encoding
= Encoding::ForLabel(label
);
28 if (encoding
== UTF_16BE_ENCODING
|| encoding
== UTF_16LE_ENCODING
) {
29 mEncoding
= UTF_8_ENCODING
;
32 if (encoding
== X_USER_DEFINED_ENCODING
) {
33 // WebKit/Blink hack for Indian and Armenian legacy sites
34 mEncoding
= WINDOWS_1252_ENCODING
;