From ae1be0785be76a86b0d0ace1ec820c2a4f3e313d Mon Sep 17 00:00:00 2001 From: John Darrington Date: Thu, 2 Apr 2009 10:26:03 +0800 Subject: [PATCH] Allow non-ascii characters to be entered as variable names. 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 | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/ui/gui/psppire-var-store.c b/src/ui/gui/psppire-var-store.c index b64bc64e..092de58c 100644 --- a/src/ui/gui/psppire-var-store.c +++ b/src/ui/gui/psppire-var-store.c @@ -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; -- 2.30.2