comparison src/main.c @ 767:e73d30e0c896

Make utf8_validate_or_convert() to always allocate a new string.
author zas_
date Fri, 30 May 2008 08:36:23 +0000
parents a336b5545af6
children 44128da39e13
comparison
equal deleted inserted replaced
766:7148e125bf23 767:e73d30e0c896
50 gdouble get_zoom_increment(void) 50 gdouble get_zoom_increment(void)
51 { 51 {
52 return ((options->image.zoom_increment != 0) ? (gdouble)options->image.zoom_increment / 10.0 : 1.0); 52 return ((options->image.zoom_increment != 0) ? (gdouble)options->image.zoom_increment / 10.0 : 1.0);
53 } 53 }
54 54
55 gchar *utf8_validate_or_convert(gchar *text) 55 gchar *utf8_validate_or_convert(const gchar *text)
56 { 56 {
57 gint len; 57 gint len;
58 58
59 if (!text) return NULL; 59 if (!text) return NULL;
60 60
61 len = strlen(text); 61 len = strlen(text);
62 if (!g_utf8_validate(text, len, NULL)) 62 if (!g_utf8_validate(text, len, NULL))
63 { 63 return g_convert(text, len, "UTF-8", "ISO-8859-1", NULL, NULL, NULL);
64 gchar *conv_text; 64
65 65 return g_strdup(text);
66 conv_text = g_convert(text, len, "UTF-8", "ISO-8859-1", NULL, NULL, NULL);
67 g_free(text);
68 text = conv_text;
69 }
70
71 return text;
72 } 66 }
73 67
74 /* Borrowed from gtkfilesystemunix.c */ 68 /* Borrowed from gtkfilesystemunix.c */
75 gchar *expand_tilde(const gchar *filename) 69 gchar *expand_tilde(const gchar *filename)
76 { 70 {