diff options
author | Pascal Rigaux <pixel@mandriva.com> | 2001-03-16 17:22:07 +0000 |
---|---|---|
committer | Pascal Rigaux <pixel@mandriva.com> | 2001-03-16 17:22:07 +0000 |
commit | ad5943b886409e3e71b9b00812287717ce63029e (patch) | |
tree | deda36cbac56db2a1ebddb3714d398b2759ea967 | |
parent | 620606f67c872194bdd85ddce81cd2330e222cff (diff) | |
download | drakx-ad5943b886409e3e71b9b00812287717ce63029e.tar drakx-ad5943b886409e3e71b9b00812287717ce63029e.tar.gz drakx-ad5943b886409e3e71b9b00812287717ce63029e.tar.bz2 drakx-ad5943b886409e3e71b9b00812287717ce63029e.tar.xz drakx-ad5943b886409e3e71b9b00812287717ce63029e.zip |
add from_utf8
-rw-r--r-- | perl-install/c/stuff.xs.pm | 27 |
1 files changed, 27 insertions, 0 deletions
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 <langinfo.h> +#include <string.h> +#include <iconv.h> + #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: |