Please send PSPP bug reports to bug-gnu-pspp@gnu.org.
-Changes from 0.8.2 to 0.8.3:
+Changes since 0.8.2:
* REGRESSION now recognises /STATISTICS=CI(x) which causes confidence
intervals for the coefficients to be printed.
+ * The SYSFILE INFO command now accepts an ENCODING subcommand to
+ specify the character encoding of string data in the system file.
+
Changes from 0.8.1 to 0.8.2:
* Charts are now rendered with colours from the Tango palette instead
is affected by these subcommands.
@pspp{} tries to automatically detect the encoding of string data in the
-file. Sometimes, however, this does not work well encoding,
+file. Sometimes, however, this does not work well,
especially for files written by old versions of SPSS or @pspp{}. Specify
the @subcmd{ENCODING} subcommand with an @acronym{IANA} character set name as its string
argument to override the default. The @subcmd{ENCODING} subcommand is a @pspp{}
@vindex SYSFILE INFO
@display
-SYSFILE INFO FILE='@var{file_name}'.
+SYSFILE INFO FILE='@var{file_name}' [ENCODING='@var{encoding}'].
@end display
@cmd{SYSFILE INFO} reads the dictionary in a system file and
Specify a file name or file handle. @cmd{SYSFILE INFO} reads that file as
a system file and displays information on its dictionary.
+@pspp{} tries to automatically detect the encoding of string data in
+the file. Sometimes, however, this does not work well, especially for
+files written by old versions of SPSS or @pspp{}. Specify the
+@subcmd{ENCODING} subcommand with an @acronym{IANA} character set name
+as its string argument to override the default. The @subcmd{ENCODING}
+subcommand is a @pspp{} extension.
+
@cmd{SYSFILE INFO} does not affect the current active dataset.
@node XEXPORT
struct tab_table *t;
struct casereader *reader;
struct sfm_read_info info;
+ char *encoding;
int r, i;
- lex_match_id (lexer, "FILE");
- lex_match (lexer, T_EQUALS);
+ h = NULL;
+ encoding = NULL;
+ for (;;)
+ {
+ lex_match (lexer, T_SLASH);
- h = fh_parse (lexer, FH_REF_FILE, NULL);
- if (!h)
- return CMD_FAILURE;
+ if (lex_match_id (lexer, "FILE") || lex_is_string (lexer))
+ {
+ lex_match (lexer, T_EQUALS);
- reader = sfm_open_reader (h, NULL, &d, &info);
- if (!reader)
+ fh_unref (h);
+ h = fh_parse (lexer, FH_REF_FILE, NULL);
+ if (h == NULL)
+ goto error;
+ }
+ else if (lex_match_id (lexer, "ENCODING"))
+ {
+ lex_match (lexer, T_EQUALS);
+
+ if (!lex_force_string (lexer))
+ goto error;
+
+ free (encoding);
+ encoding = ss_xstrdup (lex_tokss (lexer));
+
+ lex_get (lexer);
+ }
+ else
+ break;
+ }
+
+ if (h == NULL)
{
- fh_unref (h);
- return CMD_FAILURE;
+ lex_sbc_missing ("FILE");
+ goto error;
}
+
+ reader = sfm_open_reader (h, encoding, &d, &info);
+ if (!reader)
+ goto error;
+
casereader_destroy (reader);
t = tab_create (2, 11 + (info.product_ext != NULL));
fh_unref (h);
sfm_read_info_destroy (&info);
return CMD_SUCCESS;
+
+error:
+ fh_unref (h);
+ free (encoding);
+ return CMD_FAILURE;
}
\f
/* DISPLAY utility. */
/* PSPPIRE - a graphical user interface for PSPP.
- Copyright (C) 2008, 2009, 2010, 2011, 2012, 2013 Free Software Foundation
+ Copyright (C) 2008, 2009, 2010, 2011, 2012, 2013, 2014 Free Software Foundation
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
#include "ui/gui/helper.h"
#include "ui/gui/psppire-data-window.h"
#include "ui/gui/psppire-dialog-action.h"
+#include "ui/gui/psppire-encoding-selector.h"
#include "ui/gui/psppire-syntax-window.h"
#include "ui/gui/psppire-window.h"
#include "ui/gui/psppire.h"
struct string filename;
gchar *file_name =
gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
-
gchar *utf8_file_name = g_filename_to_utf8 (file_name, -1, NULL, NULL,
NULL);
+ const gchar *encoding = psppire_encoding_selector_get_encoding (
+ gtk_file_chooser_get_extra_widget (GTK_FILE_CHOOSER (dialog)));
+
gchar *syntax;
ds_init_empty (&filename);
g_free (utf8_file_name);
- syntax = g_strdup_printf ("SYSFILE INFO %s.", ds_cstr (&filename));
+ if (encoding)
+ syntax = g_strdup_printf ("SYSFILE INFO %s ENCODING='%s'.",
+ ds_cstr (&filename), encoding);
+ else
+ syntax = g_strdup_printf ("SYSFILE INFO %s.", ds_cstr (&filename));
g_free (execute_syntax_string (de, syntax));
}
/* PSPPIRE - a graphical user interface for PSPP.
- Copyright (C) 2011, 2012 Free Software Foundation, Inc.
+ Copyright (C) 2011, 2012, 2014 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
}
}
g_list_free (list);
- return encoding;
+
+ return encoding && !strcmp (encoding, "Auto") ? NULL : encoding;
}