/[pub]/test/html-webhacc/WebHACC/Output.pm
Suika

Contents of /test/html-webhacc/WebHACC/Output.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (hide annotations) (download)
Sun Jul 20 14:58:24 2008 UTC (18 years ago) by wakaba
Branch: MAIN
++ ChangeLog	20 Jul 2008 14:58:20 -0000
2008-07-20  Wakaba  <wakaba@suika.fam.cx>

	* cc.cgi: Modularized.

	* WebHACC/: New directory.

1 wakaba 1.1 package WebHACC::Output;
2     use strict;
3     require IO::Handle;
4    
5     my $htescape = sub ($) {
6     my $s = $_[0];
7     $s =~ s/&/&amp;/g;
8     $s =~ s/</&lt;/g;
9     $s =~ s/>/&gt;/g;
10     $s =~ s/"/&quot;/g;
11     $s =~ s{([\x00-\x09\x0B-\x1F\x7F-\xA0\x{FEFF}\x{FFFC}-\x{FFFF}])}{
12     sprintf '<var>U+%04X</var>', ord $1;
13     }ge;
14     return $s;
15     };
16    
17     sub new ($) {
18     return bless {nav => []}, shift;
19     } # new
20    
21     sub input ($;$) {
22     if (@_ > 1) {
23     if (defined $_[1]) {
24     $_[0]->{input} = $_[1];
25     } else {
26     delete $_[0]->{input};
27     }
28     }
29    
30     return $_[0]->{input};
31     } # input
32    
33     sub handle ($;$) {
34     if (@_ > 1) {
35     if (defined $_[1]) {
36     $_[0]->{handle} = $_[1];
37     } else {
38     delete $_[0]->{handle};
39     }
40     }
41    
42     return $_[0]->{handle};
43     } # handle
44    
45     sub set_utf8 ($) {
46     binmode shift->{handle}, ':utf8';
47     } # set_utf8
48    
49     sub set_flush ($) {
50     shift->{handle}->autoflush (1);
51     } # set_flush
52    
53     sub unset_flush ($) {
54     shift->{handle}->autoflush (0);
55     } # unset_flush
56    
57     sub html ($$) {
58     shift->{handle}->print (shift);
59     } # html
60    
61