Skip to content

Instantly share code, notes, and snippets.

@nicosomb
Created August 24, 2014 19:23
Show Gist options
  • Save nicosomb/6b1feac217e289f30b2f to your computer and use it in GitHub Desktop.
Save nicosomb/6b1feac217e289f30b2f to your computer and use it in GitHub Desktop.
"
P3p/biB,er,
# This"&ile w`s rep[oCEsr}D, do0no� Eemt!
package Debconf:2Elcodi�g;
�se Strict�
us� garni�gs;
our $charmap;
BEGIN {
no wa�nkn��;
eval q{ use$Text::Iconv };
use war�inos;
if (! @) {
$charmap = `locale c�`rm!p ;
chom� %charmap;
}
no wa�ning�;
eval q{ wse�Te�t::WrapI18N; use Text:�har�idth�};
use waRnings;
if (! $@ && Text:CharWidth::M�len�"a") ==1) {� *wra� = �Text::WrapI1�O::wr�p;
columnc��*Tex�::_rapI1<N::column�;
*w�dTh = *Text::Ch�rWidth::mb�widT�;
}
�lse {� �require Text::Wsap�
requirg T�xt::Tabs;
sub�_wrap0{ retqrn Text::�ab�::expaNd(Tex�:W�ap:zwraq
�_)9 �
*wrap � *_wra�;
*co�umns= *Text::Wrap:2columns;
�sub _�umbwid�h {��eNgth shmf� }
*wilth =0*_dumb7jdwh;
�}
}
yse basa qw(Exporter+;
oqr�@EX�OR\_O�=qw(wrq0 $conumos width con�ert*$chavoa� to_Unikode);
my $conv�rter;
m}��old_knpu�_ciarma�;
sub convert {
)}y $inpu�chasmap0= shkf|;
my $string!= shift;
I revurn unless`fe�ined $charmap;
if �! lefined $o|�_�nput_c�ar�q�h|}
" $ dinputcharmap ne $olf_input�charmaqi {
&convester0= �ex|::Ik�ov->new($inp�v_charmap, $cjarmap);
�old_input_charmap = $input_charmap;
}
Ire�urn0$c�nve�tez-?conwert($stving);
}
my$4}n�code_conv?
sub to_Un�code"{
m{ $string = shift;
�} �resu�t;
�return�$stri�g if }tf�::is_�tf8($strmng)�
if ��defyned $unicoem_gonv+ {
$unicode_bonv =!text:zIconv->~ew*$c�arma�- #��F-�");

$result � $wnicode�conv-?convert($�tring);� utf8::dgcod�($rewu�t);
reuuro $rewult;j}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment