summaryrefslogtreecommitdiff
path: root/render
diff options
context:
space:
mode:
authorJames Bursa <james@netsurf-browser.org>2004-04-17 16:00:16 +0000
committerJames Bursa <james@netsurf-browser.org>2004-04-17 16:00:16 +0000
commit455efb4fb7977977fd12b47b7d7e719febfca821 (patch)
tree6bf2eb8fc0dc0b3a3076d1bb5f57738c3c911c3d /render
parent27816b80df349a3f1c41780c151170c857be7e86 (diff)
downloadnetsurf-455efb4fb7977977fd12b47b7d7e719febfca821.tar.gz
netsurf-455efb4fb7977977fd12b47b7d7e719febfca821.tar.bz2
[project @ 2004-04-17 16:00:16 by bursa]
Supply XML_CHAR_ENCODING_NONE to libxml2 when no encoding is specified so that meta charsets are used. svn path=/import/netsurf/; revision=788
Diffstat (limited to 'render')
-rw-r--r--render/html.c25
1 files changed, 12 insertions, 13 deletions
diff --git a/render/html.c b/render/html.c
index 999cd4e48..c3a9b87b4 100644
--- a/render/html.c
+++ b/render/html.c
@@ -54,7 +54,7 @@ void html_create(struct content *c, const char *params[])
unsigned int i;
struct content_html_data *html = &c->data.html;
- html->encoding = XML_CHAR_ENCODING_8859_1;
+ html->encoding = XML_CHAR_ENCODING_NONE;
html->getenc = true;
for (i = 0; params[i]; i += 2) {
@@ -62,7 +62,7 @@ void html_create(struct content *c, const char *params[])
html->encoding = xmlParseCharEncoding(params[i + 1]);
html->getenc = false; /* encoding specified - trust the server... */
if (html->encoding == XML_CHAR_ENCODING_ERROR) {
- html->encoding = XML_CHAR_ENCODING_8859_1;
+ html->encoding = XML_CHAR_ENCODING_NONE;
html->getenc = true;
}
break;
@@ -95,21 +95,20 @@ void html_create(struct content *c, const char *params[])
void html_process_data(struct content *c, char *data, unsigned long size)
{
unsigned long x;
- LOG(("content %s, size %lu", c->url, size));
- /*cache_dump();*/
- /* First time through, check if we need to get the encoding
- * if so, get it and reset the parser instance with it.
- * if it fails, assume Latin1
+
+ /* First time through, check if we need to detect the encoding
+ * if so, detect it and reset the parser instance with it.
*/
if (c->data.html.getenc) {
- c->data.html.encoding = xmlDetectCharEncoding(data, size);
- if (c->data.html.encoding == XML_CHAR_ENCODING_ERROR ||
- c->data.html.encoding == XML_CHAR_ENCODING_NONE)
- c->data.html.encoding = XML_CHAR_ENCODING_8859_1;
- xmlSwitchEncoding(c->data.html.parser, c->data.html.encoding);
+ xmlCharEncoding encoding = xmlDetectCharEncoding(data, size);
+ if (encoding != XML_CHAR_ENCODING_ERROR &&
+ encoding != XML_CHAR_ENCODING_NONE) {
+ xmlSwitchEncoding(c->data.html.parser, encoding);
+ c->data.html.encoding = encoding;
+ }
c->data.html.getenc = false;
- LOG(("Encoding: %s", xmlGetCharEncodingName(c->data.html.encoding)));
}
+
for (x = 0; x + CHUNK <= size; x += CHUNK) {
htmlParseChunk(c->data.html.parser, data + x, CHUNK, 0);
gui_multitask();