w->opts = *opts;
- w->encoding = (dict_get_encoding (dict)
- ? xstrdup (dict_get_encoding (dict))
- : NULL);
+ w->encoding = xstrdup (dict_get_encoding (dict));
w->n_csv_vars = dict_get_var_cnt (dict);
w->csv_vars = xnmalloc (w->n_csv_vars, sizeof *w->csv_vars);
static void dict_unset_split_var (struct dictionary *, struct variable *);
static void dict_unset_mrset_var (struct dictionary *, struct variable *);
+/* Returns the encoding for data in dictionary D. The return value is a
+ nonnull string that contains an IANA character set name. */
const char *
dict_get_encoding (const struct dictionary *d)
{
/* Set the new dictionary's encoding early so that string length limitations
are interpreted correctly. */
- if ( s->encoding)
- d->encoding = xstrdup (s->encoding);
+ d->encoding = xstrdup (s->encoding);
for (i = 0; i < s->var_cnt; i++)
{
write_encoding_record (struct sfm_writer *w,
const struct dictionary *d)
{
- if (dict_get_encoding (d) != NULL)
- {
- /* IANA says "...character set names may be up to 40 characters taken
- from the printable characters of US-ASCII," so character set names
- don't need to be recoded to be in UTF-8.
-
- We convert encoding names to uppercase because SPSS writes encoding
- names in uppercase. */
- char *encoding = xstrdup (dict_get_encoding (d));
- str_uppercase (encoding);
- write_string_record (w, ss_cstr (encoding), 20);
- free (encoding);
- }
+ /* IANA says "...character set names may be up to 40 characters taken
+ from the printable characters of US-ASCII," so character set names
+ don't need to be recoded to be in UTF-8.
+
+ We convert encoding names to uppercase because SPSS writes encoding
+ names in uppercase. */
+ char *encoding = xstrdup (dict_get_encoding (d));
+ str_uppercase (encoding);
+ write_string_record (w, ss_cstr (encoding), 20);
+ free (encoding);
}
-
/* Writes the long variable name table. */
static void
write_longvar_table (struct sfm_writer *w, const struct dictionary *dict)
tab_text (t, 0, 10, TAB_LEFT, _("Charset:"));
- tab_text (t, 1, 10, TAB_LEFT,
- dict_get_encoding(d) ? dict_get_encoding(d) : _("Unknown"));
+ tab_text (t, 1, 10, TAB_LEFT, dict_get_encoding (d));
tab_submit (t);