From ebc32d5da492feb87c39004f5169c44f1db8f811 Mon Sep 17 00:00:00 2001 From: Pascal Rigaux Date: Wed, 5 Mar 2008 11:02:14 +0000 Subject: - genhdlist2: o use utf8:: functions instead of Encode (to be able to work with only perl base modules) --- NEWS | 4 ++++ genhdlist2 | 17 +++++++++-------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/NEWS b/NEWS index 1eb993f..593b102 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,7 @@ +- genhdlist2: + o use utf8:: functions instead of Encode + (to be able to work with only perl base modules) + Version 5.4 - 26 February 2008, by Pascal "Pixel" Rigaux - parsehdlist, rpm2header: diff --git a/genhdlist2 b/genhdlist2 index cc1a682..d42158d 100644 --- a/genhdlist2 +++ b/genhdlist2 @@ -5,7 +5,6 @@ use URPM; use MDV::Packdrakeng; use Getopt::Long; -use Encode; main(); @@ -237,14 +236,16 @@ sub close_xml { } sub ensure_utf8 { - my ($s) = @_; - - 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'); + 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 } sub encode_xml { -- cgit v1.2.1