* automake.mk: Add new file.
[pspp-builds.git] / src / data / data-out.c
index 967f57eddc23bf2090360032d26fb20417b01728..02ff06572fabcb1f282c2b9aa51319ee32ae0850 100644 (file)
@@ -92,11 +92,12 @@ static void output_hex (const void *, size_t bytes, char *);
 \f
 /* Converts the INPUT value into printable form in the exactly
    FORMAT->W characters in OUTPUT according to format
-   specification FORMAT.  No null terminator is appended to the
-   buffer.  */
+   specification FORMAT.  The output is recoded from native form
+   into the given legacy character ENCODING.  No null terminator
+   is appended to the buffer.  */
 void
-data_out (const union value *input, const struct fmt_spec *format,
-          char *output)
+data_out_legacy (const union value *input, enum legacy_encoding encoding,
+                 const struct fmt_spec *format, char *output)
 {
   static data_out_converter_func *const converters[FMT_NUMBER_OF_FORMATS] =
     {
@@ -107,6 +108,17 @@ data_out (const union value *input, const struct fmt_spec *format,
   assert (fmt_check_output (format));
 
   converters[format->type] (input, format, output);
+  if (encoding != LEGACY_NATIVE
+      && fmt_get_category (format->type) != FMT_CAT_BINARY)
+    legacy_recode (LEGACY_NATIVE, output, encoding, output, format->w);
+}
+
+/* Same as data_out_legacy with ENCODING set to LEGACY_NATIVE.  */
+void
+data_out (const union value *value, const struct fmt_spec *format,
+          char *output)
+{
+  return data_out_legacy (value, LEGACY_NATIVE, format, output);
 }
 
 /* Returns the current output integer format. */