Mercurial > bins
changeset 9:0f248ad86f9f 1.1.29.e2
bins_edit: try to get encoding stuff right, move it into main
author | Peter Gervai <grin@grin.hu> |
---|---|
date | Thu, 16 Oct 2008 00:11:14 +0200 |
parents | c28af937b9bd |
children | f962189bab94 |
files | bins_edit |
diffstat | 1 files changed, 20 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- 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) {