+ // NB: We convert input file to wchar_t here in Unicode mode, based on
+ // either Content-Type header or <meta> tags. In ANSI mode, we don't
+ // do it as it is done by wxHtmlParser (for this reason, we add <meta>
+ // tag if we used Content-Type header).
+#if wxUSE_UNICODE
+ int charsetPos;
+ if ((charsetPos = file.GetMimeType().Find(_T("; charset="))) != wxNOT_FOUND)
+ {
+ wxString charset = file.GetMimeType().Mid(charsetPos + 10);
+ wxCSConv conv(charset);
+ ReadString(doc, s, conv);
+ }
+ else
+ {
+ size_t size = s->GetSize();
+ wxCharBuffer buf( size+1 );
+ s->Read( buf.data(), size );
+ *(buf.data() + size) = 0;
+ wxString tmpdoc( buf, wxConvISO8859_1);
+
+ wxString charset = wxHtmlParser::ExtractCharsetInformation(tmpdoc);
+ if (charset.empty())
+ doc = tmpdoc;
+ else
+ {
+ wxCSConv conv(charset);
+ doc = wxString( buf, conv );
+ }
+ }
+#else // !wxUSE_UNICODE
+ ReadString(doc, s, wxConvLibc);