#include "wx/wxprec.h"
#include "wx/defs.h"
-#if wxUSE_HTML
+#if wxUSE_HTML && wxUSE_STREAMS
#ifdef __BORDLANDC__
#pragma hdrstop
#endif
#ifndef WXPRECOMP
-#include "wx/wx.h"
+ #include "wx/log.h"
+ #include "wx/intl.h"
#endif
#include "wx/html/htmlfilt.h"
wxString doc, doc2;
if (s == NULL) return wxEmptyString;
- src = new char[s -> GetSize()+1];
- src[s -> GetSize()] = 0;
- s -> Read(src, s -> GetSize());
+ src = new char[s->GetSize()+1];
+ src[s->GetSize()] = 0;
+ s->Read(src, s->GetSize());
doc = src;
delete [] src;
- doc.Replace("<", "<", TRUE);
- doc.Replace(">", ">", TRUE);
+ doc.Replace(wxT("<"), wxT("<"), TRUE);
+ doc.Replace(wxT(">"), wxT(">"), TRUE);
doc2 = "<HTML><BODY><PRE>\n" + doc + "\n</PRE></BODY></HTML>";
return doc2;
}
bool wxHtmlFilterImage::CanRead(const wxFSFile& file) const
{
- return (file.GetMimeType().Left(6) == "image/");
+ return (file.GetMimeType().Left(6) == wxT("image/"));
}
char *src;
wxString doc;
- if (s == NULL) return wxEmptyString;
- src = new char[s -> GetSize() + 1];
- src[s -> GetSize()] = 0;
- s -> Read(src, s -> GetSize());
+ if (s == NULL)
+ {
+ wxLogError(_("Cannot open HTML document: %s"), file.GetLocation().c_str());
+ return wxEmptyString;
+ }
+ src = new char[s->GetSize() + 1];
+ src[s->GetSize()] = 0;
+ s->Read(src, s->GetSize());
doc = src;
delete[] src;
+ // add meta tag if we obtained this through http:
+ if (file.GetMimeType().Find(_T("; charset=")) == 0)
+ {
+ wxString s(_T("<meta http-equiv=\"Content-Type\" content=\""));
+ s << file.GetMimeType() << _T("\">");
+ return s+doc;
+ }
+
return doc;
}