From ad5943b886409e3e71b9b00812287717ce63029e Mon Sep 17 00:00:00 2001 From: Pascal Rigaux Date: Fri, 16 Mar 2001 17:22:07 +0000 Subject: add from_utf8 --- perl-install/c/stuff.xs.pm | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'perl-install/c/stuff.xs.pm') diff --git a/perl-install/c/stuff.xs.pm b/perl-install/c/stuff.xs.pm index 26b5004af..590053618 100644 --- a/perl-install/c/stuff.xs.pm +++ b/perl-install/c/stuff.xs.pm @@ -40,6 +40,10 @@ print ' '; $ENV{C_RPM} and print ' +#include +#include +#include + #undef Fflush #undef Mkdir #undef Stat @@ -427,6 +431,29 @@ setPromVars(linuxAlias, bootDevice) '; $ENV{C_RPM} and print ' +char * +from_utf8(s) + char *s + CODE: + char *charset = nl_langinfo(CODESET); + iconv_t cd = iconv_open(charset, "utf-8"); + RETVAL = s; + if (cd != (iconv_t) (-1)) { + int s_len = strlen(RETVAL); + char *buf = alloca(2 * s_len); + { + char *ptr = buf; + int ptr_len = s_len; + if ((iconv(cd, &s, &s_len, &ptr, &ptr_len)) != (size_t) (-1)) { + *ptr = 0; + RETVAL = buf; + } + } + iconv_close(cd); + } + OUTPUT: + RETVAL + int rpmReadConfigFiles() CODE: -- cgit v1.2.1