comparison bins_edit @ 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
comparison
equal deleted inserted replaced
8:c28af937b9bd 9:0f248ad86f9f
41 41
42 my $verbose = 1; 42 my $verbose = 1;
43 my $html=0; 43 my $html=0;
44 44
45 my $localEncoding; 45 my $localEncoding;
46 $localEncoding = `locale charmap`;
47 chomp $localEncoding;
48 if ($? != 0 ) {
49 $localEncoding = "LATIN1";
50 } else {
51 if (! $localEncoding or ($localEncoding eq "ANSI_X3.4-1968")) {
52 chop($localEncoding);
53 # ANSI is unspeakably primitive, promote it.
54 $localEncoding = "LATIN1";
55 print "Forcing encoding to $localEncoding\n" if ($verbose >=2);
56 }
57 }
58 my $converter = Text::Iconv->new($localEncoding, "UTF-8");
59 print "Using $localEncoding encoding on input\n" if ($verbose >=2);
60 46
61 # decode HTML entites which doesn't exist in XML 47 # decode HTML entites which doesn't exist in XML
62 sub decodeEntites{ 48 sub decodeEntites{
63 my $s = shift; 49 my $s = shift;
64 50
381 367
382 exit 1; 368 exit 1;
383 } 369 }
384 370
385 371
372 sub determine_encoding {
373 $localEncoding = `locale charmap`;
374 chomp $localEncoding;
375 if ($? != 0 ) {
376 $localEncoding = "LATIN1";
377 } else {
378 if (! $localEncoding or ($localEncoding eq "ANSI_X3.4-1968")) {
379 chop($localEncoding);
380 # ANSI is unspeakably primitive, promote it.
381 $localEncoding = "LATIN1";
382 print "Forcing encoding to $localEncoding\n" if ($verbose >=2);
383 }
384 }
385 my $converter = Text::Iconv->new($localEncoding, "UTF-8");
386 print "Using $localEncoding encoding on input\n" if ($verbose >=2);
387 }
388
389
386 sub main{ 390 sub main{
387 my %values; 391 my %values;
388 my $album = 0; # 1 if it a album description file 392 my $album = 0; # 1 if it a album description file
389 393
390 394
409 ) 413 )
410 or usage(1); 414 or usage(1);
411 415
412 print "Verbosity is $verbose\n" if $verbose>1; 416 print "Verbosity is $verbose\n" if $verbose>1;
413 417
418 &determine_encoding;
419
414 my @files; 420 my @files;
415 if ($#ARGV < 0) { 421 if ($#ARGV < 0) {
416 if ($album) { 422 if ($album) {
417 @files = ("."); 423 @files = (".");
418 } else { 424 } else {