Read dictionary encoding from data files.
[pspp-builds.git] / src / data / dictionary.c
index ba840898112494b775d02c810edee29c98037fee..1c50ac7feb26976ea1e9b63d835961a5ae3db243 100644 (file)
@@ -63,6 +63,9 @@ struct dictionary
     struct vector **vector;     /* Vectors of variables. */
     size_t vector_cnt;          /* Number of vectors. */
     struct attrset attributes;  /* Custom attributes. */
+
+    char *encoding;             /* Character encoding of string data */
+
     const struct dict_callbacks *callbacks; /* Callbacks on dictionary
                                               modification */
     void *cb_data ;                  /* Data passed to callbacks */
@@ -71,6 +74,20 @@ struct dictionary
     void *changed_data;
   };
 
+
+void
+dict_set_encoding (struct dictionary *d, const char *enc)
+{
+  d->encoding = strdup (enc);
+}
+
+const char *
+dict_get_encoding (const struct dictionary *d)
+{
+  return d->encoding ;
+}
+
+
 void
 dict_set_change_callback (struct dictionary *d,
                          void (*changed) (struct dictionary *, void*),
@@ -194,6 +211,8 @@ dict_clone (const struct dictionary *s)
   for (i = 0; i < s->vector_cnt; i++)
     d->vector[i] = vector_clone (s->vector[i], s, d);
 
+  d->encoding = strdup (s->encoding);
+
   dict_set_attributes (d, dict_get_attributes (s));
 
   return d;