aboutsummaryrefslogtreecommitdiffstats
path: root/Rpmdrake/formatting.pm
diff options
context:
space:
mode:
Diffstat (limited to 'Rpmdrake/formatting.pm')
-rw-r--r--Rpmdrake/formatting.pm14
1 files changed, 14 insertions, 0 deletions
diff --git a/Rpmdrake/formatting.pm b/Rpmdrake/formatting.pm
index bf8aa987..8b1ab479 100644
--- a/Rpmdrake/formatting.pm
+++ b/Rpmdrake/formatting.pm
@@ -35,6 +35,7 @@ use Exporter;
our @ISA = qw(Exporter);
our @EXPORT = qw(
$spacing
+ ensure_utf8
format_changelog_changelogs
format_changelog_string
format_field
@@ -50,6 +51,19 @@ our @EXPORT = qw(
urpm_name);
+# 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
+ }
+ Encode::_utf8_on($_[0]); #- now we know it is valid utf8
+ $_[0];
+}
+
sub rpm_description {
my ($description) = @_;
utf8::decode($description);