aboutsummaryrefslogtreecommitdiffstats
path: root/grpmi
diff options
context:
space:
mode:
authorGuillaume Cottenceau <gc@mandriva.com>2003-04-07 22:11:56 +0000
committerGuillaume Cottenceau <gc@mandriva.com>2003-04-07 22:11:56 +0000
commit31f3868ba08f510730266c1a2e717aceb872ae6e (patch)
tree69f7beb6730fe452fe7dd00f9934041bedadde2d /grpmi
parent33e24f9003f2704c4ab2f4f91bb5b57dc2829140 (diff)
downloadrpmdrake-31f3868ba08f510730266c1a2e717aceb872ae6e.tar
rpmdrake-31f3868ba08f510730266c1a2e717aceb872ae6e.tar.gz
rpmdrake-31f3868ba08f510730266c1a2e717aceb872ae6e.tar.bz2
rpmdrake-31f3868ba08f510730266c1a2e717aceb872ae6e.tar.xz
rpmdrake-31f3868ba08f510730266c1a2e717aceb872ae6e.zip
fix yet again an UTF8 problem (#3676)
Diffstat (limited to 'grpmi')
-rw-r--r--grpmi/rpm/grpmi_rpm.xs28
1 files changed, 27 insertions, 1 deletions
diff --git a/grpmi/rpm/grpmi_rpm.xs b/grpmi/rpm/grpmi_rpm.xs
index f63cdca2..72b4de28 100644
--- a/grpmi/rpm/grpmi_rpm.xs
+++ b/grpmi/rpm/grpmi_rpm.xs
@@ -29,6 +29,8 @@
#include <sys/stat.h>
#include <errno.h>
#include <stdarg.h>
+#include <langinfo.h>
+#include <iconv.h>
#include "EXTERN.h"
#include "perl.h"
@@ -72,6 +74,30 @@ char * init_rcstuff_(void)
}
+/* bad bad bad.. duplicated code from gi/perl-install/c/stuff.xs */
+char* std_to_utf8(char* s)
+{
+ iconv_t cd = iconv_open("UTF-8", nl_langinfo(CODESET));
+ char* retval = s;
+ if (cd != (iconv_t) (-1)) {
+ size_t s_len = strlen(retval);
+ /* the maximum expansion when converting happens when converting
+ tscii to utf-8; each tscii char can become up to 4 unicode chars
+ and each one of those unicode chars can be 3 bytes long */
+ char *buf = alloca(4 * 3 * s_len);
+ {
+ char *ptr = buf;
+ size_t ptr_len = 4 * 3 * s_len;
+ if ((iconv(cd, &s, &s_len, &ptr, &ptr_len)) != (size_t) (-1)) {
+ *ptr = 0;
+ retval = buf;
+ }
+ }
+ iconv_close(cd);
+ }
+ return strdup(retval);
+}
+
/* these are in rpmlib but not in rpmlib.h */
int readLead(FD_t fd, struct rpmlead *lead);
int rpmReadSignature(FD_t fd, Header *header, short sig_type);
@@ -144,7 +170,7 @@ char * verify_sig_(char * file)
i = rpmVerifySignature(tmpfile, tag, ptr, count, result);
if (i != RPMSIG_OK) {
unlink(tmpfile);
- return strdup(result);
+ return std_to_utf8(result);
}
}
unlink(tmpfile);