@display
DATA LIST [FIXED]
@{TABLE,NOTABLE@}
- [FILE='file-name']
+ [FILE='file-name' [ENCODING='encoding']]
[RECORDS=record_count]
[END=end_var]
[SKIP=record_count]
file handle (@pxref{File Handles}). If the FILE subcommand is not used,
then input is assumed to be specified within the command file using
@cmd{BEGIN DATA}@dots{}@cmd{END DATA} (@pxref{BEGIN DATA}).
+The ENCODING subcommand may only be used if the FILE subcommand is also used.
+It specifies the character encoding of the file.
The optional RECORDS subcommand, which takes a single integer as an
argument, is used to specify the number of lines per record. If RECORDS
DATA LIST FREE
[(@{TAB,'c'@}, @dots{})]
[@{NOTABLE,TABLE@}]
- [FILE='file-name']
+ [FILE='file-name' [ENCODING='encoding']]
[SKIP=record_cnt]
/var_spec@dots{}
DATA LIST LIST
[(@{TAB,'c'@}, @dots{})]
[@{NOTABLE,TABLE@}]
- [FILE='file-name']
+ [FILE='file-name' [ENCODING='encoding']]
[SKIP=record_count]
/var_spec@dots{}
struct dictionary *dict;
struct data_parser *parser;
struct dfm_reader *reader;
- struct variable *end;
- struct file_handle *fh;
+ struct variable *end = NULL;
+ struct file_handle *fh = NULL;
+ struct string encoding = DS_EMPTY_INITIALIZER;
int table;
enum data_parser_type type;
dict = in_input_program () ? dataset_dict (ds) : dict_create ();
parser = data_parser_create ();
reader = NULL;
- end = NULL;
- fh = NULL;
table = -1; /* Print table if nonzero, -1=undecided. */
has_type = false;
if (fh == NULL)
goto error;
}
+ else if (lex_match_id (lexer, "ENCODING"))
+ {
+ lex_match (lexer, '=');
+ if (!lex_force_string (lexer))
+ goto error;
+
+ ds_init_string (&encoding, lex_tokstr (lexer));
+
+ lex_get (lexer);
+ }
else if (lex_match_id (lexer, "RECORDS"))
{
lex_match (lexer, '=');
}
type = data_parser_get_type (parser);
+ if (! ds_is_empty (&encoding))
+ {
+ if ( NULL == fh)
+ msg (MW, _("Encoding should not be specified for inline data. It will be ignored."));
+ else
+ dict_set_encoding (dict, ds_cstr (&encoding));
+ }
+
if (fh == NULL)
fh = fh_inline_file ();
fh_set_default_handle (fh);