summaryrefslogtreecommitdiffstats
path: root/perl-install/c/stuff.xs.pl
diff options
context:
space:
mode:
authorGuillaume Cottenceau <gc@mandriva.com>2002-12-06 15:24:35 +0000
committerGuillaume Cottenceau <gc@mandriva.com>2002-12-06 15:24:35 +0000
commite4eb514f7217d7832ef899754205791b44e82fdf (patch)
tree683dbb72ec66e7aab1b40e21c1f9bb857e888d88 /perl-install/c/stuff.xs.pl
parent31ddca4ffe90c41464aa33e70bf8638c12dff062 (diff)
downloaddrakx-backup-do-not-use-e4eb514f7217d7832ef899754205791b44e82fdf.tar
drakx-backup-do-not-use-e4eb514f7217d7832ef899754205791b44e82fdf.tar.gz
drakx-backup-do-not-use-e4eb514f7217d7832ef899754205791b44e82fdf.tar.bz2
drakx-backup-do-not-use-e4eb514f7217d7832ef899754205791b44e82fdf.tar.xz
drakx-backup-do-not-use-e4eb514f7217d7832ef899754205791b44e82fdf.zip
add bind_textdomain_codeset, iconv the dgettext results to UTF8 since perl seems to mess with that when trying to do so from within gtk2-perl (with sv_utf8_upgrade)
Diffstat (limited to 'perl-install/c/stuff.xs.pl')
-rw-r--r--perl-install/c/stuff.xs.pl50
1 files changed, 34 insertions, 16 deletions
diff --git a/perl-install/c/stuff.xs.pl b/perl-install/c/stuff.xs.pl
index b1ec93bd2..99bd4fd5f 100644
--- a/perl-install/c/stuff.xs.pl
+++ b/perl-install/c/stuff.xs.pl
@@ -102,6 +102,25 @@ void initIMPS2() {
void log_message(const char * s, ...) {}
+SV * iconv_(char* s, char* from_charset, char* to_charset) {
+ iconv_t cd = iconv_open(to_charset, from_charset);
+ char* retval = s;
+ if (cd != (iconv_t) (-1)) {
+ size_t s_len = strlen(retval);
+ char *buf = alloca(3 * s_len + 10); /* 10 for safety, it should not be needed */
+ {
+ char *ptr = buf;
+ size_t ptr_len = 3 * s_len + 10;
+ if ((iconv(cd, &s, &s_len, &ptr, &ptr_len)) != (size_t) (-1)) {
+ *ptr = 0;
+ retval = buf;
+ }
+ }
+ iconv_close(cd);
+ }
+ return newSVpv(retval, 0);
+}
+
';
print '
@@ -217,10 +236,23 @@ bindtextdomain(domainname, dirname)
char * dirname
char *
+bind_textdomain_codeset(domainname, codeset)
+ char * domainname
+ char * codeset
+
+SV *
dgettext(domainname, msgid)
char * domainname
char * msgid
+ CODE:
+ /* always convert to UTF8, because perl will fail to do it correctly during install (in gtk2-perl) */
+ RETVAL = iconv_(dgettext(domainname, msgid), nl_langinfo(CODESET), "UTF-8");
+ SvUTF8_on(RETVAL);
+
+ OUTPUT:
+ RETVAL
+
int
KTYP(x)
int x
@@ -496,27 +528,13 @@ setPromVars(linuxAlias, bootDevice)
char *linuxAlias
char *bootDevice
-char *
+SV *
iconv(s, from_charset, to_charset)
char *s
char *from_charset
char *to_charset
CODE:
- iconv_t cd = iconv_open(to_charset, from_charset);
- RETVAL = s;
- if (cd != (iconv_t) (-1)) {
- size_t s_len = strlen(RETVAL);
- char *buf = alloca(3 * s_len + 10); /* 10 for safety, it should not be needed */
- {
- char *ptr = buf;
- size_t ptr_len = 3 * s_len + 10;
- if ((iconv(cd, &s, &s_len, &ptr, &ptr_len)) != (size_t) (-1)) {
- *ptr = 0;
- RETVAL = buf;
- }
- }
- iconv_close(cd);
- }
+ RETVAL = iconv_(s, from_charset, to_charset);
OUTPUT:
RETVAL