]> www.wagner.pp.ru Git - oss/imgwww.git/blobdiff - imagedir
Support for utf-8 output
[oss/imgwww.git] / imagedir
index 9d66c098f1b6ed014456f1ea2e0bef287cb09271..3ca94031475af9f5ddbc1741b34c7b9b1c830559 100755 (executable)
--- a/imagedir
+++ b/imagedir
@@ -1,4 +1,8 @@
 #!/usr/bin/perl
+use utf8;
+use Encode;
+use locale;
+use open OUT => ":locale";
 use constant THUMBSIZE => 150;
 use constant COLUMNS=>5;
 use constant THUMBDIR=>".thumbs";
@@ -60,7 +64,7 @@ my $dir = $opt_t || (split ("/",cwd()))[-1];
 mkdir THUMBDIR if (! -d THUMBDIR);
 mkdir INLINEDIR if (! -d INLINEDIR);
 my $i=0;
-open OUT,">index.html";
+open OUT,">","index.html";
 print OUT "<HTML><HEAD><TITLE>$dir</TITLE>\n<BODY>\n<H1>$dir</H1>\n"
 ."<p align=\"center\"><A HREF=\"..\">back</A></p>". 
  "<TABLE CELLSPACING=10 CELLPADDING=0 BORDER=0>\n";
@@ -117,9 +121,7 @@ sub rescale {
 
 sub make_comment_html {
   my $info = shift;
-my $comment =
-
-       ref($info->{"Comment"})?join("\n",@{$info->{"Comment"}}):$info->{"Comment"};
+my $comment = Encode::decode("koi8-r",ref($info->{"Comment"})?join("\n",@{$info->{"Comment"}}):$info->{"Comment"});
        $comment =~s/\&/&amp;/;
        $comment =~s/"/&quot;/;
        $comment =~s/>/&gt;/;
@@ -132,7 +134,7 @@ sub make_html {
        my $info = shift;
        my $comment = shift;
        my $inline = shift;
-       open HTML, ">$imgfile.html";
+       open HTML, ">", "$imgfile.html";
        my ($w,$h) = dim($info);
        my ($w1,$h1) = dim(image_info(INLINEDIR."/".$imgfile));
        print HTML "<html><head><title>$dir:$imgfile</title></head><body>