diff src/main.c @ 645:b50deb0f9968

Rename bar_exif_validate_text() to utf8_validate_or_convert() and move it to main.[ch].
author zas_
date Mon, 12 May 2008 23:21:35 +0000
parents 8cc9f349c670
children e34c1002e553
line wrap: on
line diff
--- a/src/main.c	Mon May 12 23:00:04 2008 +0000
+++ b/src/main.c	Mon May 12 23:21:35 2008 +0000
@@ -120,6 +120,25 @@
 	return ((options->image.zoom_increment != 0) ? (gdouble)options->image.zoom_increment / 10.0 : 1.0);
 }
 
+gchar *utf8_validate_or_convert(gchar *text)
+{
+	gint len;
+
+	if (!text) return NULL;
+	
+	len = strlen(text);
+	if (!g_utf8_validate(text, len, NULL))
+		{
+		gchar *conv_text;
+
+		conv_text = g_convert(text, len, "UTF-8", "ISO-8859-1", NULL, NULL, NULL);
+		g_free(text);
+		text = conv_text;
+		}
+
+	return text;
+}
+
 
 /*
  *-----------------------------------------------------------------------------