3 #include <data/data-in.h>
4 #include <libpspp/message.h>
9 /* Formats a value according to FORMAT
10 The returned string must be freed when no longer required */
12 value_to_text(union value v, struct fmt_spec format)
16 s = g_new(gchar, format.w + 1);
17 if ( ! data_out(s, &format, &v) )
19 g_warning("Can't format missing discrete value \n");
30 text_to_value(const gchar *text, union value *v,
31 struct fmt_spec format)
35 if ( format.type != FMT_A)
37 if ( ! text ) return FALSE;
40 const gchar *s = text;
48 if ( !*s) return FALSE;
53 di.e = text + strlen(text);
55 di.flags = DI_IGNORE_ERROR;
65 get_widget_assert(GladeXML *xml, const gchar *name)
71 w = glade_xml_get_widget(xml, name);
74 g_warning("Widget \"%s\" could not be found\n", name);
79 /* Converts a string in the pspp locale to utf-8 */
81 pspp_locale_to_utf8(const gchar *text, gssize len, GError **err)
83 GError *tmp_error = 0;
90 s = g_locale_to_utf8(text, len, 0, 0, &tmp_error);
94 g_warning("Error converting to UTF8: %s", tmp_error->message);
95 g_propagate_error (err, tmp_error);