summaryrefslogtreecommitdiffstats
path: root/urpm
diff options
context:
space:
mode:
Diffstat (limited to 'urpm')
-rw-r--r--urpm/msg.pm14
1 files changed, 13 insertions, 1 deletions
diff --git a/urpm/msg.pm b/urpm/msg.pm
index 00dc5b75..151f016b 100644
--- a/urpm/msg.pm
+++ b/urpm/msg.pm
@@ -3,7 +3,7 @@ package urpm::msg;
use strict;
use Exporter;
our @ISA = 'Exporter';
-our @EXPORT = qw(N log_it to_utf8 message_input message toMb);
+our @EXPORT = qw(N log_it to_utf8 message_input message toMb from_utf8);
#- I18N.
eval {
@@ -13,6 +13,18 @@ eval {
Locale::gettext::textdomain("urpmi");
};
+my $codeset; #- encoding of the current locale
+eval {
+ require I18N::Langinfo;
+ I18N::Langinfo->import(qw(langinfo CODESET));
+ $codeset = langinfo(CODESET()); # note the ()
+};
+
+sub from_utf8_full { Locale::gettext::iconv($_[0], "UTF-8", $codeset) }
+sub from_utf8_dummy { $_[0] }
+
+*from_utf8 = defined $codeset ? *from_utf8_full : *from_utf8_dummy;
+
sub N {
my ($format, @params) = @_;
sprintf(