# HG changeset patch # User Peter Gervai # Date 1224108674 -7200 # Node ID 0f248ad86f9f3c461b16da902ae15e0506978453 # Parent c28af937b9bd191e5b8bb00b9ead25c811515c36 bins_edit: try to get encoding stuff right, move it into main diff -r c28af937b9bd -r 0f248ad86f9f bins_edit --- a/bins_edit Thu Oct 16 00:06:40 2008 +0200 +++ b/bins_edit Thu Oct 16 00:11:14 2008 +0200 @@ -43,20 +43,6 @@ my $html=0; my $localEncoding; -$localEncoding = `locale charmap`; -chomp $localEncoding; -if ($? != 0 ) { - $localEncoding = "LATIN1"; -} else { - if (! $localEncoding or ($localEncoding eq "ANSI_X3.4-1968")) { - chop($localEncoding); - # ANSI is unspeakably primitive, promote it. - $localEncoding = "LATIN1"; - print "Forcing encoding to $localEncoding\n" if ($verbose >=2); - } -} -my $converter = Text::Iconv->new($localEncoding, "UTF-8"); -print "Using $localEncoding encoding on input\n" if ($verbose >=2); # decode HTML entites which doesn't exist in XML sub decodeEntites{ @@ -383,6 +369,24 @@ } +sub determine_encoding { + $localEncoding = `locale charmap`; + chomp $localEncoding; + if ($? != 0 ) { + $localEncoding = "LATIN1"; + } else { + if (! $localEncoding or ($localEncoding eq "ANSI_X3.4-1968")) { + chop($localEncoding); + # ANSI is unspeakably primitive, promote it. + $localEncoding = "LATIN1"; + print "Forcing encoding to $localEncoding\n" if ($verbose >=2); + } + } + my $converter = Text::Iconv->new($localEncoding, "UTF-8"); + print "Using $localEncoding encoding on input\n" if ($verbose >=2); +} + + sub main{ my %values; my $album = 0; # 1 if it a album description file @@ -411,6 +415,8 @@ print "Verbosity is $verbose\n" if $verbose>1; + &determine_encoding; + my @files; if ($#ARGV < 0) { if ($album) {