+ *dest = '\0';
+ return result;
+}
+--- rpm-4.4.2.org/lib/formats.c 2005-01-26 05:46:54.000000000 +0100
++++ rpm-4.4.2/lib/formats.c 2007-02-13 20:50:01.082623000 +0100
+@@ -301,6 +301,7 @@
+ char * t, * te;
+ unsigned long anint = 0;
+ int xx;
++ int freeit = 0;
+
+ /*@-branchstate@*/
+ switch (type) {
+@@ -308,6 +309,10 @@
+ case RPM_STRING_TYPE:
+ s = data;
+ xtag = "string";
++ /* XXX Force utf8 strings. */
++ s = xstrdup(s);
++ s = xstrtolocale(s);
++ freeit = 1;
+ break;
+ case RPM_BIN_TYPE:
+ { int cpl = b64encode_chars_per_line;
+@@ -321,6 +326,7 @@
+ b64encode_chars_per_line = cpl;
+ /*@=mods@*/
+ xtag = "base64";
++ freeit = 1;
+ } break;
+ case RPM_CHAR_TYPE:
+ case RPM_INT8_TYPE:
+@@ -367,7 +373,7 @@
+
+ /* XXX s was malloc'd */
+ /*@-branchstate@*/
+- if (!strcmp(xtag, "base64"))
++ if (freeit)
+ s = _free(s);
+ /*@=branchstate@*/
+
+@@ -1077,6 +1083,7 @@
+
+ if (rc && (*data) != NULL) {
+ *data = xstrdup(*data);
++ *data = xstrtolocale(*data);
+ *freeData = 1;
+ return 0;
+ }