summaryrefslogtreecommitdiff
path: root/src/input
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2008-06-28 20:55:43 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2008-06-28 20:55:43 +0000
commit5784a7659386a8681445d85837a70b45ed7d6968 (patch)
tree06e16bfdedac1720986fdb3d566276c212dc61bb /src/input
parent70023ca2ae3478b92c277c36173c5563390b9a57 (diff)
downloadlibparserutils-5784a7659386a8681445d85837a70b45ed7d6968.tar.gz
libparserutils-5784a7659386a8681445d85837a70b45ed7d6968.tar.bz2
Update filter's input encoding when it's been auto-detected.
svn path=/trunk/libparserutils/; revision=4471
Diffstat (limited to 'src/input')
-rw-r--r--src/input/inputstream.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/input/inputstream.c b/src/input/inputstream.c
index fd44995..9cbcdd2 100644
--- a/src/input/inputstream.c
+++ b/src/input/inputstream.c
@@ -306,6 +306,8 @@ parserutils_error parserutils_inputstream_refill_buffer(
/* If this is the first chunk of data, we must detect the charset and
* strip the BOM, if one exists */
if (!stream->done_first_chunk) {
+ parserutils_filter_optparams params;
+
if (stream->csdetect != NULL) {
error = stream->csdetect(stream->raw->data,
stream->raw->length,
@@ -323,6 +325,16 @@ parserutils_error parserutils_inputstream_refill_buffer(
if (stream->mibenum == 0)
abort();
+ /* Ensure filter is using the correct encoding */
+ params.encoding.name =
+ parserutils_charset_mibenum_to_name(stream->mibenum);
+
+ error = parserutils_filter_setopt(stream->input,
+ PARSERUTILS_FILTER_SET_ENCODING,
+ &params);
+ if (error != PARSERUTILS_OK)
+ return error;
+
error = parserutils_inputstream_strip_bom(stream->mibenum,
stream->raw);
if (error != PARSERUTILS_OK)