From d62348801fa2eaae0c9fa96e5a6a0b9612fbc27d Mon Sep 17 00:00:00 2001 From: Thierry Vignaud Date: Mon, 26 Mar 2012 18:21:41 +0000 Subject: (ensure_utf8) sync with genhdlist2 and use utf8:: functions instead of Encode --- Rpmdrake/formatting.pm | 17 +++++++++-------- Rpmdrake/pkg.pm | 2 +- Rpmdrake/rpmnew.pm | 2 +- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/Rpmdrake/formatting.pm b/Rpmdrake/formatting.pm index de78fb80..6f581b9e 100644 --- a/Rpmdrake/formatting.pm +++ b/Rpmdrake/formatting.pm @@ -54,15 +54,16 @@ our @EXPORT = qw( # from rpmtools, #37482: sub ensure_utf8 { - my ($s) = @_; - require Encode; - Encode::_utf8_on($s); #- this is done on the copy - if (!Encode::is_utf8($s, 1)) { - Encode::_utf8_off($_[0]); - Encode::from_to($_[0], 'iso-8859-15', 'utf8'); # most probable + if (utf8::is_utf8($_[0])) { + utf8::valid($_[0]) and return; + + utf8::encode($_[0]); #- disable utf8 flag + utf8::upgrade($_[0]); + } else { + utf8::decode($_[0]); #- try to set utf8 flag + utf8::valid($_[0]) and return; + warn "do not know what to with $_[0]\n"; } - Encode::_utf8_on($_[0]); #- now we know it is valid utf8 - $_[0]; } sub rpm_description { diff --git a/Rpmdrake/pkg.pm b/Rpmdrake/pkg.pm index b8c8a690..fb51cca1 100644 --- a/Rpmdrake/pkg.pm +++ b/Rpmdrake/pkg.pm @@ -83,7 +83,7 @@ sub run_rpm { foreach (qw(LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT LC_IDENTIFICATION LC_ALL)) { local $ENV{$_} = $ENV{$_} . '.UTF-8' if $ENV{$_} && $ENV{$_} !~ /UTF-8/; } - my @l = map { ensure_utf8($_) } run_program::get_stdout(@_); + my @l = map { ensure_utf8($_); $_ } run_program::get_stdout(@_); wantarray() ? @l : join('', @l); } diff --git a/Rpmdrake/rpmnew.pm b/Rpmdrake/rpmnew.pm index fc6377d6..f3cf5ba5 100644 --- a/Rpmdrake/rpmnew.pm +++ b/Rpmdrake/rpmnew.pm @@ -77,7 +77,7 @@ sub inspect { foreach (qw(LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT LC_IDENTIFICATION LC_ALL)) { local $ENV{$_} = $ENV{$_} . '.UTF-8' if $ENV{$_} && $ENV{$_} !~ /UTF-8/; } - my @diff = map { ensure_utf8($_) } `/usr/bin/diff -u '$file' '$rpmnew'`; + my @diff = map { ensure_utf8($_); $_ } `/usr/bin/diff -u '$file' '$rpmnew'`; @diff = N("(none)") if !@diff; my $d = ugtk2->new(N("Inspecting %s", $file), grab => 1, transient => $::main_window); my $save_wsize = sub { @inspect_wsize = $d->{rwindow}->get_size }; -- cgit v1.2.1