summaryrefslogtreecommitdiffstats
path: root/perl-install
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2001-06-08 18:04:41 +0000
committerPascal Rigaux <pixel@mandriva.com>2001-06-08 18:04:41 +0000
commit260fe6ccef437482f2e1e40655a9100a1e8f18df (patch)
tree29e4bafb4f30c91faff8f147eebac667dab74c35 /perl-install
parentad3541c3f289f4777ebea4bcd0a12954edfb9780 (diff)
downloaddrakx-backup-do-not-use-260fe6ccef437482f2e1e40655a9100a1e8f18df.tar
drakx-backup-do-not-use-260fe6ccef437482f2e1e40655a9100a1e8f18df.tar.gz
drakx-backup-do-not-use-260fe6ccef437482f2e1e40655a9100a1e8f18df.tar.bz2
drakx-backup-do-not-use-260fe6ccef437482f2e1e40655a9100a1e8f18df.tar.xz
drakx-backup-do-not-use-260fe6ccef437482f2e1e40655a9100a1e8f18df.zip
- c::iconv replace c::from_utf8 and c::to_utf8
- handle po files in any charset, iconv'ed to the right charset
Diffstat (limited to 'perl-install')
-rw-r--r--perl-install/any.pm2
-rw-r--r--perl-install/c/stuff.pm2
-rw-r--r--perl-install/c/stuff.xs.pm31
-rw-r--r--perl-install/lang.pm2
4 files changed, 12 insertions, 25 deletions
diff --git a/perl-install/any.pm b/perl-install/any.pm
index a1a2da268..a4710b375 100644
--- a/perl-install/any.pm
+++ b/perl-install/any.pm
@@ -801,6 +801,6 @@ sub runlevel {
}
}
-sub to_utf8 { c::to_utf8($lang::charset || 'ISO-8859-1', $_[0]) }
+sub to_utf8 { c::iconv($_[0], $lang::charset || 'ISO-8859-1', "utf-8") }
1;
diff --git a/perl-install/c/stuff.pm b/perl-install/c/stuff.pm
index d7f8db2cb..0121f2904 100644
--- a/perl-install/c/stuff.pm
+++ b/perl-install/c/stuff.pm
@@ -10,6 +10,8 @@ $VERSION = '0.01';
bootstrap c::stuff $VERSION;
+sub from_utf8 { iconv($_[0], "utf-8", standard_charset()) }
+
sub headerGetEntry {
my ($h, $q) = @_;
$h or log::l("empty header in headerGetEntry"), return;
diff --git a/perl-install/c/stuff.xs.pm b/perl-install/c/stuff.xs.pm
index 14d9ddeb5..475da7664 100644
--- a/perl-install/c/stuff.xs.pm
+++ b/perl-install/c/stuff.xs.pm
@@ -452,18 +452,19 @@ setPromVars(linuxAlias, bootDevice)
$ENV{C_RPM} and print '
char *
-from_utf8(s)
+iconv(s, from_charset, to_charset)
char *s
+ char *from_charset
+ char *to_charset
CODE:
- char *charset = nl_langinfo(CODESET);
- iconv_t cd = iconv_open(charset, "utf-8");
+ iconv_t cd = iconv_open(to_charset, from_charset);
RETVAL = s;
if (cd != (iconv_t) (-1)) {
int s_len = strlen(RETVAL);
- char *buf = alloca(s_len + 10); /* 10 for safety, it should not be needed, utf8 is *always* bigger than a special encoding */
+ char *buf = alloca(3 * s_len + 10); /* 10 for safety, it should not be needed */
{
char *ptr = buf;
- int ptr_len = s_len + 10;
+ int ptr_len = 3 * s_len + 10;
if ((iconv(cd, &s, &s_len, &ptr, &ptr_len)) != (size_t) (-1)) {
*ptr = 0;
RETVAL = buf;
@@ -475,25 +476,9 @@ from_utf8(s)
RETVAL
char *
-to_utf8(charset, s)
- char *charset
- char *s
+standard_charset()
CODE:
- iconv_t cd = iconv_open("utf-8", charset);
- RETVAL = s;
- if (cd != (iconv_t) (-1)) {
- int s_len = strlen(RETVAL);
- char *buf = alloca(2 * s_len + 10); /* 10 for safety, it should not be needed */
- {
- char *ptr = buf;
- int ptr_len = 2 * s_len + 10;
- if ((iconv(cd, &s, &s_len, &ptr, &ptr_len)) != (size_t) (-1)) {
- *ptr = 0;
- RETVAL = buf;
- }
- }
- iconv_close(cd);
- }
+ RETVAL = nl_langinfo(CODESET);
OUTPUT:
RETVAL
diff --git a/perl-install/lang.pm b/perl-install/lang.pm
index 80e87fbc1..92b653548 100644
--- a/perl-install/lang.pm
+++ b/perl-install/lang.pm
@@ -448,7 +448,7 @@ sub load_po {
$to = qq("$to");
}
if ($from) {
- $s .= qq("$from" => $to,\n);
+ $s .= qq("$from" => ) . c::iconv($to, $lang::charset, c::standard_charset()) . ",\n";
} elsif ($to =~ /charset=([\w-]+)/) {
$lang::charset = $1;
}