]> www.wagner.pp.ru Git - oss/imgwww.git/commitdiff
Support for utf-8 output
authorVictor Wagner <vitus@wagner.pp.ru>
Mon, 15 Sep 2014 20:23:21 +0000 (00:23 +0400)
committerVictor Wagner <vitus@wagner.pp.ru>
Mon, 15 Sep 2014 20:23:21 +0000 (00:23 +0400)
archivedir
imagedir

index 54b48d9aede8428eba41aca4e1a81d9fce720fe6..1a5e0dfad0db029b53a5a5d27f6cb5b9ed4481a5 100755 (executable)
@@ -1,23 +1,23 @@
 #!/usr/bin/tclsh
 
 array set monName {
-01 "ñÎ×ÁÒÑ"
-02 "æÅ×ÒÁÌÑ"
-03 "íÁÒÔÁ"
-04 "áÐÒÅÌÑ"
-05 "íÁÑ"
-06 "éÀÎÑ"
-07 "éÀÌÑ"
-08 "á×ÇÕÓÔÁ"
-09 "óÅÎÔÑÂÒÑ"
-10 "ïËÔÑÂÒÑ"
-11 "îÏÑÂÒÑ"
-12 "äÅËÁÂÒÑ"
+01 "\u042f\u043d\u0432\u0430\u0440\u044f"
+02 "\u0424\u0435\u0432\u0440\u0430\u043b\u044f"
+03 "\u041c\u0430\u0440\u0442\u0430"
+04 "\u0410\u043f\u0440\u0435\u043b\u044f"
+05 "\u041c\u0430\u044f"
+06 "\u0418\u044e\u043d\u044f"
+07 "\u0418\u044e\u043b\u044f"
+08 "\u0410\u0432\u0433\u0443\u0441\u0442\u0430"
+09 "\u0421\u0435\u043d\u0442\u044f\u0431\u0440\u044f"
+10 "\u041e\u043a\u0442\u044f\u0431\u0440\u044f"
+11 "\u041d\u043e\u044f\u0431\u0440\u044f"
+12 "\u0414\u0435\u043a\u0430\u0431\u0440\u044f"
 }
 
 proc year_header {year items} {
-       return "<h2>$year ÇÏÄ</h2><ul>"
-#      return "<table border=1 width=\"100%\" cellspacing=0><tr><td align=\"center\" colspan=\"$items\"><b><font size=+2>$year ÇÏÄ</font></td></tr>\n<tr>"
+       return "<h2>$year \u0433\u043e\u0434</h2><ul>"
+#      return "<table border=1 width=\"100%\" cellspacing=0><tr><td align=\"center\" colspan=\"$items\"><b><font size=+2>$year \u0433\u043e\u0434</font></td></tr>\n<tr>"
 }
 
 proc year_footer {year} {
@@ -31,8 +31,8 @@ proc out_item { month day place dir} {
 #      return "<td align=center><a href=\"$dir\">$day $monName($month)<br>$place</a></td>"
 }
 set f [open "index.html" w]
-puts $f "<HTML><HEAD><TITLE>áÒÈÉ× ÆÏÔÏÇÒÁÆÉÊ</TITLE></HEAD><BODY>
-<H1>áÒÈÉ× ÆÏÔÏÇÒÁÆÉÊ</H1>"
+puts $f "<HTML><HEAD><TITLE>\u0410\u0440\u0445\u0438\u0432 \u0444\u043e\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u0439</TITLE></HEAD><BODY>
+<H1>\u0410\u0440\u0445\u0438\u0432 \u0444\u043e\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u0439</H1>"
 foreach dirname [lsort -decreasing [glob *]] {
        if {![regexp {^(\d{4})\.(\d{2})\.(\d{2}(-\d{2})?)-(.*)$} $dirname \
                        match year month day xxx place]} {
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>