#define _(msgid) gettext (msgid)
#define N_(msgid) msgid
-
+#include <libpspp/i18n.h>
#include <gobject/gvaluecollector.h>
static void psppire_var_store_finalize (GObject *object);
-gchar * missing_values_to_string (const struct variable *pv, GError **err);
-
-
static gchar *psppire_var_store_get_string (const PsppireSheetModel *sheet_model, glong row, glong column);
static gboolean psppire_var_store_clear (PsppireSheetModel *model, glong row, glong col);
static glong psppire_var_store_get_row_count (const PsppireSheetModel * model);
static glong psppire_var_store_get_column_count (const PsppireSheetModel * model);
-static gchar *text_for_column (const struct variable *pv, gint c, GError **err);
+static gchar *text_for_column (PsppireVarStore *vs, const struct variable *pv,
+ gint c, GError **err);
static GObjectClass *parent_class = NULL;
}
static gchar *
-psppire_var_store_get_string (const PsppireSheetModel *model, glong row, glong column)
+psppire_var_store_get_string (const PsppireSheetModel *model,
+ glong row, glong column)
{
PsppireVarStore *store = PSPPIRE_VAR_STORE (model);
pv = psppire_dict_get_variable (store->dict, row);
- return text_for_column (pv, column, 0);
+ return text_for_column (store, pv, column, 0);
}
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 = recode_string (psppire_dict_encoding (var_store->dict),
+ UTF8,
+ text, -1);
+ var_set_label (pv, s);
+ free (s);
+ return TRUE;
+ }
break;
case PSPPIRE_VAR_STORE_COL_TYPE:
case PSPPIRE_VAR_STORE_COL_VALUES:
static const gchar none[] = N_("None");
static gchar *
-text_for_column (const struct variable *pv, gint c, GError **err)
+text_for_column (PsppireVarStore *vs,
+ const struct variable *pv, gint c, GError **err)
{
+ PsppireDict *dict = vs->dict;
static const gchar *const type_label[] =
{
N_("Numeric"),
switch (c)
{
case PSPPIRE_VAR_STORE_COL_NAME:
- return pspp_locale_to_utf8 ( var_get_name (pv), -1, err);
+ return recode_string (UTF8, psppire_dict_encoding (dict),
+ var_get_name (pv), -1);
break;
case PSPPIRE_VAR_STORE_COL_TYPE:
{
}
break;
case PSPPIRE_VAR_STORE_COL_LABEL:
- return pspp_locale_to_utf8 (var_get_label (pv), -1, err);
+ return recode_string (UTF8, psppire_dict_encoding (dict),
+ var_get_label (pv), -1);
break;
case PSPPIRE_VAR_STORE_COL_MISSING:
{
- return missing_values_to_string (pv, err);
+ return missing_values_to_string (dict, pv, err);
}
break;
case PSPPIRE_VAR_STORE_COL_VALUES:
val_labs_done (&ip);
- ss = pspp_locale_to_utf8 (gstr->str, gstr->len, err);
+ ss = recode_string (UTF8, psppire_dict_encoding (dict),
+ gstr->str, gstr->len);
g_string_free (gstr, TRUE);
return ss;
}