Allow non-ascii characters to be entered as variable names.
authorJohn Darrington <john@darrington.wattle.id.au>
Thu, 2 Apr 2009 02:26:03 +0000 (10:26 +0800)
committerJohn Darrington <john@darrington.wattle.id.au>
Thu, 2 Apr 2009 02:26:03 +0000 (10:26 +0800)
Previously, only ascii could be used in the name of a variable,
so the variable sheet did not bother converting.  Now we have
to convert the encoding.

src/ui/gui/psppire-var-store.c

index b64bc64ee79c805d3e21cf58a4de56b4077be995..092de58cafa0ed89f827d61a617c9008a442e86a 100644 (file)
@@ -467,14 +467,15 @@ psppire_var_store_set_string (PsppireSheetModel *model,
     {
     case PSPPIRE_VAR_STORE_COL_NAME:
       {
-       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;
+       gboolean ok;
+       char *s = recode_string (psppire_dict_encoding (var_store->dict),
+                                UTF8,
+                                text, -1);
+
+       ok =  psppire_dict_rename_var (var_store->dict, pv, s);
+
+       free (s);
+       return ok;
       }
     case PSPPIRE_VAR_STORE_COL_COLUMNS:
       if ( ! text) return FALSE;