From bf9fe2e8d3aaf93b68ea191f19086b8ac9759fc5 Mon Sep 17 00:00:00 2001 From: Sven Neumann Date: Mon, 16 Feb 2004 11:47:17 +0000 Subject: [PATCH] unset the GIOChannel's encoding before trying to find and parse the XML 2004-02-16 Sven Neumann * app/config/gimpxmlparser.c (gimp_xml_parser_parse_io_channel): unset the GIOChannel's encoding before trying to find and parse the XML header. --- ChangeLog | 6 ++++++ app/config/gimpxmlparser.c | 13 +++++++++---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index fda3d7769a..190a1fca0f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2004-02-16 Sven Neumann + + * app/config/gimpxmlparser.c (gimp_xml_parser_parse_io_channel): + unset the GIOChannel's encoding before trying to find and parse + the XML header. + 2004-02-15 Michael Natterer * libgimp/gimpdrawable.c (gimp_drawable_get): warn and return NULL diff --git a/app/config/gimpxmlparser.c b/app/config/gimpxmlparser.c index a865531a3b..3b21b35c78 100644 --- a/app/config/gimpxmlparser.c +++ b/app/config/gimpxmlparser.c @@ -94,6 +94,8 @@ gimp_xml_parser_parse_file (GimpXmlParser *parser, if (!io) return FALSE; + g_io_channel_set_encoding (io, NULL, NULL); + success = gimp_xml_parser_parse_io_channel (parser, io, error); g_io_channel_unref (io); @@ -137,7 +139,7 @@ gimp_xml_parser_parse_io_channel (GimpXmlParser *parser, g_return_val_if_fail (error == NULL || *error == NULL, FALSE); io_encoding = g_io_channel_get_encoding (io); - if (io_encoding && strcmp (io_encoding, "UTF-8")) + if (io_encoding) { g_warning ("gimp_xml_parser_parse_io_channel():\n" "The encoding has already been set on this GIOChannel!"); @@ -147,8 +149,7 @@ gimp_xml_parser_parse_io_channel (GimpXmlParser *parser, /* try to determine the encoding */ while (len < sizeof (buffer)) { - status = g_io_channel_read_chars (io, - buffer + len, 1, &bytes, error); + status = g_io_channel_read_chars (io, buffer + len, 1, &bytes, error); len += bytes; if (status == G_IO_STATUS_ERROR) @@ -162,11 +163,15 @@ gimp_xml_parser_parse_io_channel (GimpXmlParser *parser, if (encoding) { - if (!g_io_channel_set_encoding (io, encoding, error)) + if (! g_io_channel_set_encoding (io, encoding, error)) return FALSE; g_free (encoding); } + else + { + g_io_channel_set_encoding (io, "UTF-8", NULL); + } while (TRUE) {