struct dfm_writer *writer; /* Output file, NULL=listing file. */
struct ll_list specs; /* List of struct prt_out_specs. */
size_t record_cnt; /* Number of records to write. */
- struct string line; /* Output buffer. */
+ struct u8_line line; /* Output buffer. */
+
+ int unit; /* Unit width, in bytes. */
+ char one[MAX_UNIT]; /* '1' in encoding, 'unit' bytes long. */
+ char space[MAX_UNIT]; /* \n in encoding, 'unit' bytes long. */
};
enum which_formats
trns->writer = NULL;
trns->record_cnt = 0;
ll_init (&trns->specs);
- ds_init_empty (&trns->line);
- ds_register_pool (&trns->line, trns->pool);
+ u8_line_init (&trns->line);
+ u8_line_register_pool (&trns->line, trns->pool);
tmp_pool = pool_create_subpool (trns->pool);
int record = 1;
struct prt_out_spec *spec;
- ds_clear (&trns->line);
- ds_put_byte (&trns->line, ' ');
+ u8_line_clear (&trns->line);
+
+ ds_put_byte (&trns->line.s, ' ');
+ trns->line.width = 0;
+
ll_for_each (spec, struct prt_out_spec, ll, &trns->specs)
{
flush_records (trns, spec->record, &eject, &record);
- ds_set_length (&trns->line, spec->first_column, encoded_space);
if (spec->type == PRT_VAR)
{
const union value *input = case_data (*c, spec->var);
if (!spec->sysmis_as_spaces || input->f != SYSMIS)
- data_out_recode (input, var_get_encoding (spec->var),
- &spec->format, &trns->line, trns->encoding);
+ {
+ char *s = data_out (input, var_get_encoding (spec->var),
+ &spec->format);
+ int width = u8_strwidth (s);
+ size_t n = strlen (s);
+ u8_line_put (&trns->line, spec->first_column,
+ spec->first_column + width, s, n);
+ free (s);
+ }
else
+ {
+ memset (u8_line-record
+
+ }
ds_put_byte_multiple (&trns->line, encoded_space, spec->format.w);
if (spec->add_space)
ds_put_byte (&trns->line, encoded_space);
else
{
ds_put_substring (&trns->line, ds_ss (&spec->string));
- if (0 != strcmp (trns->encoding, C_ENCODING))
+ if (0 != strcmp (trns->encoding, UTF8))
{
size_t length = ds_length (&spec->string);
char *data = ss_data (ds_tail (&trns->line, length));
- char *s = recode_string (trns->encoding, C_ENCODING, data, length);
+ char *s = recode_string (trns->encoding, UTF8, data, length);
memcpy (data, s, length);
free (s);
}