MRSETS: Recode counted value to UTF-8 before displaying.
authorBen Pfaff <blp@cs.stanford.edu>
Mon, 25 Apr 2011 04:41:02 +0000 (21:41 -0700)
committerBen Pfaff <blp@cs.stanford.edu>
Tue, 26 Apr 2011 04:13:53 +0000 (21:13 -0700)
Otherwise they display incorrectly if a counted value contains
non-ASCII characters.

src/language/dictionary/mrsets.c

index f607ac928f4f48039183569e5ea6d235a0344a62..621cdc884b1e2fff1eaa256a30314243e242f201 100644 (file)
@@ -579,8 +579,14 @@ parse_display (struct lexer *lexer, struct dictionary *dict)
           if (mrset->width == 0)
             ds_put_format (&details, "%.0f\n", mrset->counted.f);
           else
-            ds_put_format (&details, "`%.*s'\n", mrset->width,
-                           value_str (&mrset->counted, mrset->width));
+            {
+              const uint8_t *raw = value_str (&mrset->counted, mrset->width);
+              char *utf8 = recode_string ("UTF-8", dict_get_encoding (dict),
+                                          CHAR_CAST (const char *, raw),
+                                          mrset->width);
+              ds_put_format (&details, "`%s'\n", utf8);
+              free (utf8);
+            }
           ds_put_format (&details, "%s: %s\n", _("Category label source"),
                          (mrset->cat_source == MRSET_VARLABELS
                           ? _("Variable labels")