From 5784a7659386a8681445d85837a70b45ed7d6968 Mon Sep 17 00:00:00 2001 From: John Mark Bell Date: Sat, 28 Jun 2008 20:55:43 +0000 Subject: Update filter's input encoding when it's been auto-detected. svn path=/trunk/libparserutils/; revision=4471 --- src/input/inputstream.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/input') 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, + ¶ms); + if (error != PARSERUTILS_OK) + return error; + error = parserutils_inputstream_strip_bom(stream->mibenum, stream->raw); if (error != PARSERUTILS_OK) -- cgit v1.2.3