return recode_string (CONV_PSPP_TO_UTF8, text, len);
}
+gchar *
+utf8_to_pspp_locale (const gchar *text, gssize len, GError **err)
+{
+ return recode_string (CONV_UTF8_TO_PSPP, text, len);
+}
+
+
#define _(msgid) gettext (msgid)
#define N_(msgid) msgid
GtkWidget * get_widget_assert (GtkBuilder *builder, const gchar *name);
/* Converts a string in the pspp locale to utf-8 */
-char * pspp_locale_to_utf8 (const gchar *text, gssize len, GError **err);
+gchar * pspp_locale_to_utf8 (const gchar *text, gssize len, GError **err);
+gchar * utf8_to_pspp_locale (const gchar *text, gssize len, GError **err);
void connect_help (GtkBuilder *);
psppire_data_store_set_string (PsppireDataStore *store,
const gchar *text, glong row, glong col)
{
+ gchar *s;
glong n_cases;
const struct variable *pv = psppire_dict_get_variable (store->dict, col);
if ( NULL == pv)
if (row == n_cases)
psppire_data_store_insert_new_case (store, row);
+ s = utf8_to_pspp_locale (text, -1, NULL);
+
psppire_data_store_data_in (store, row,
- var_get_case_index (pv), ss_cstr (text),
+ var_get_case_index (pv), ss_cstr (s),
var_get_write_format (pv));
+ free (s);
psppire_sheet_model_range_changed (PSPPIRE_SHEET_MODEL (store), row, col, row, col);
switch (col)
{
case PSPPIRE_VAR_STORE_COL_NAME:
- return psppire_dict_rename_var (var_store->dict, pv, text);
- break;
+ {
+ int i;
+ /* Until non-ascii in variable names is better managed,
+ simply refuse to allow them to be entered. */
+ for (i = 0 ; i < strlen (text) ; ++i )
+ if (!g_ascii_isprint (text[i]))
+ return FALSE;
+ return psppire_dict_rename_var (var_store->dict, pv, text);
+ break;
+ }
case PSPPIRE_VAR_STORE_COL_COLUMNS:
if ( ! text) return FALSE;
var_set_display_width (pv, atoi (text));
}
break;
case PSPPIRE_VAR_STORE_COL_LABEL:
- var_set_label (pv, text);
- return TRUE;
+ {
+ gchar *s = utf8_to_pspp_locale (text, -1, NULL);
+ var_set_label (pv, s);
+ free (s);
+ return TRUE;
+ }
break;
case PSPPIRE_VAR_STORE_COL_TYPE:
case PSPPIRE_VAR_STORE_COL_VALUES: