UTF-8 validate all strings and try g_locale_to_utf8() as fallback if it

2002-05-30  Michael Natterer  <mitch@gimp.org>

	* app/xcf/xcf-read.c (xcf_read_string): UTF-8 validate all strings
	and try g_locale_to_utf8() as fallback if it fails.

2002-05-30  Michael Natterer  <mitch@gimp.org>

	* POTFILES.in: added app/xcf/xcf-read.c
This commit is contained in:
Michael Natterer 2002-05-30 14:37:35 +00:00 committed by Michael Natterer
parent 0f8e0a80e9
commit 98849323f3
4 changed files with 35 additions and 2 deletions

View file

@ -1,3 +1,8 @@
2002-05-30 Michael Natterer <mitch@gimp.org>
* app/xcf/xcf-read.c (xcf_read_string): UTF-8 validate all strings
and try g_locale_to_utf8() as fallback if it fails.
2002-05-30 Sven Neumann <sven@gimp.org>
* configure.in: check for extra libraries needed for inet_ntoa() and

View file

@ -24,6 +24,8 @@
#include "xcf-read.h"
#include "libgimp/gimpintl.h"
guint
xcf_read_int32 (FILE *fp,
@ -91,8 +93,29 @@ xcf_read_string (FILE *fp,
total += xcf_read_int32 (fp, &tmp, 1);
if (tmp > 0)
{
data[i] = g_new (gchar, tmp);
total += xcf_read_int8 (fp, (guint8*) data[i], tmp);
gchar *str;
str = g_new (gchar, tmp);
total += xcf_read_int8 (fp, (guint8*) str, tmp);
if (str[tmp - 1] != '\0')
str[tmp - 1] = '\0';
if (! g_utf8_validate (str, -1, NULL))
{
gchar *utf8_str;
utf8_str = g_locale_to_utf8 (str, -1, NULL, NULL, NULL);
g_free (str);
if (utf8_str)
str = utf8_str;
else
str = g_strdup (_("(invalid UTF-8 string)"));
}
data[i] = str;
}
else
{

View file

@ -1,3 +1,7 @@
2002-05-30 Michael Natterer <mitch@gimp.org>
* POTFILES.in: added app/xcf/xcf-read.c
2002-05-29 Ole Laursen <olau@hardworking.dk>
* da.po: Changed translation of redo.

View file

@ -197,6 +197,7 @@ app/widgets/gimpwidgets-constructors.c
app/widgets/gimpwidgets-utils.c
app/xcf/xcf-load.c
app/xcf/xcf-read.c
app/xcf/xcf.c
modules/cdisplay_gamma.c