+/* Write variable sets. */
+static void
+write_varsets (struct sfm_writer *w, const struct dictionary *dict)
+{
+ const char *encoding = dict_get_encoding (dict);
+
+ if (is_encoding_ebcdic_compatible (encoding))
+ {
+ /* FIXME. */
+ return;
+ }
+
+ size_t n_varsets = dict_get_n_varsets (dict);
+ if (n_varsets == 0)
+ return;
+
+ struct string s = DS_EMPTY_INITIALIZER;
+ for (size_t i = 0; i < n_varsets; i++)
+ {
+ const struct varset *varset = dict_get_varset (dict, i);
+
+ char *name = recode_string (encoding, "UTF-8", varset->name, -1);
+ ds_put_format (&s, "%s= ", name);
+ free (name);
+
+ for (size_t j = 0; j < varset->n_vars; j++)
+ {
+ if (j)
+ ds_put_byte (&s, ' ');
+
+ const char *name_utf8 = var_get_name (varset->vars[j]);
+ char *name = recode_string (encoding, "UTF-8", name_utf8, -1);
+ ds_put_cstr (&s, name);
+ free (name);
+ }
+ ds_put_byte (&s, '\n');
+ }
+
+ if (!ds_is_empty (&s))
+ write_string_record (w, ds_ss (&s), 5);
+ ds_destroy (&s);
+}
+