summaryrefslogtreecommitdiff
path: root/riscos/save_complete.c
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2005-05-21 15:59:19 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2005-05-21 15:59:19 +0000
commit2233db5b7d0d73506ffd13fef3cc0366713d64a0 (patch)
tree2d98ffa11371d00b0bee844ff86a4b0ff9cdaaa3 /riscos/save_complete.c
parentd8608af81238608f800b489d5e8754b7b5bb7fca (diff)
downloadnetsurf-2233db5b7d0d73506ffd13fef3cc0366713d64a0.tar.gz
netsurf-2233db5b7d0d73506ffd13fef3cc0366713d64a0.tar.bz2
[project @ 2005-05-21 15:59:19 by jmb]
Fix encoding handling when full saving svn path=/import/netsurf/; revision=1727
Diffstat (limited to 'riscos/save_complete.c')
-rw-r--r--riscos/save_complete.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/riscos/save_complete.c b/riscos/save_complete.c
index 519181188..db2858ac8 100644
--- a/riscos/save_complete.c
+++ b/riscos/save_complete.c
@@ -10,6 +10,7 @@
* Save HTML document with dependencies (implementation).
*/
+#define _GNU_SOURCE /* for strndup */
#include <assert.h>
#include <ctype.h>
#include <errno.h>
@@ -17,6 +18,7 @@
#include <sys/types.h>
#include <regex.h>
#include "libxml/HTMLtree.h"
+#include "libxml/parserInternals.h"
#include "oslib/osfile.h"
#include "netsurf/utils/config.h"
#include "netsurf/content/content.h"
@@ -184,7 +186,23 @@ bool save_complete_html(struct content *c, const char *path, bool index)
warn_user("NoMemory", 0);
return false;
}
- /** \todo set parser charset */
+ /* set parser charset */
+ if (c->data.html.encoding) {
+ xmlCharEncodingHandler *enc_handler;
+ enc_handler =
+ xmlFindCharEncodingHandler(c->data.html.encoding);
+ if (enc_handler) {
+ xmlCtxtResetLastError(parser);
+ if (xmlSwitchToEncoding(parser, enc_handler)) {
+ xmlFreeDoc(parser->myDoc);
+ htmlFreeParserCtxt(parser);
+ warn_user("MiscError",
+ "Encoding switch failed");
+ return false;
+ }
+ }
+ }
+
htmlParseDocument(parser);
/* rewrite all urls we know about */