From 2233db5b7d0d73506ffd13fef3cc0366713d64a0 Mon Sep 17 00:00:00 2001 From: John Mark Bell Date: Sat, 21 May 2005 15:59:19 +0000 Subject: [project @ 2005-05-21 15:59:19 by jmb] Fix encoding handling when full saving svn path=/import/netsurf/; revision=1727 --- riscos/save_complete.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) 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 #include #include @@ -17,6 +18,7 @@ #include #include #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 */ -- cgit v1.2.3