From f7f95effe736c3a2a84f02cf405770b850fe1489 Mon Sep 17 00:00:00 2001 From: Chris Little Date: Mon, 23 Apr 2007 21:13:23 +0000 Subject: added detection/conversion of Latin-1 files git-svn-id: https://www.crosswire.org/svn/sword-tools/trunk@82 07627401-56e2-0310-80f4-f8cd0041bdcd --- modules/perlconverters/zef2osis.pl | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'modules/perlconverters/zef2osis.pl') diff --git a/modules/perlconverters/zef2osis.pl b/modules/perlconverters/zef2osis.pl index be740d0..848a489 100644 --- a/modules/perlconverters/zef2osis.pl +++ b/modules/perlconverters/zef2osis.pl @@ -93,11 +93,17 @@ sub delempty { return $iline; } +$enc = "utf8"; + $q = 0; foreach $line (@data) { if ($pr == 1) { + if ($enc ne "utf8") { + utf8::encode($line); + } + $line =~ s/[\r\n]+/\n/g; $line =~ s/^\s+//; $line =~ s/\s+$//; @@ -167,7 +173,11 @@ foreach $line (@data) { print OUTF "$line\n"; } } - if ($line =~ /<\/INFORMATION>/) { + elsif ($line =~ /<\?xml .*?encoding=\"[Ii][Ss][Oo]\-8859\-1\"\?>/) { + use encoding 'latin1'; + $enc = "latin1"; + } + elsif ($line =~ /<\/INFORMATION>/) { $pr = 1; } -- cgit