#!/usr/local/bin/perl -w

use CGI;
my $cgi = new CGI();
my $page = $cgi->param("page") || 0;
my $start= $page * 256;

$table  = make_table($start, 16,16);

print <<EOF;
content-type: text/html


<head>
<title>Character Set</title>
<style>
 body {
 	font-family: Syntax, Arial, Geneva, sans-serif;
	font-size: 14pt;
 }
 small {
	font-size: 9pt;
 }
 .info {
    font-family: Courier New, Courier;
	color: #006699;
	font-size: 9pt;
 }
</style>
</head>
<body bgcolor=white>

<table cellpadding=0 cellspacing=0 width=100% height=100% border=0>

$table

<tr>
<td bgcolor=#dddddd colspan=12 align=center><b>
<script language=javascript>
  document.write(navigator.userAgent)
</script>
</b></td>
<td>&amp;#<i>x</i><br>
    <i>x</i>
</td>
<td><small><i>dec</i><br>
    <i>hex</i></small>
</td>
<td align=right bgcolor=#dddddd colspan=18 class=info>
	<a href="why_charset.html" target=info>what for</a>? &nbsp;  &nbsp;  &nbsp; 
/** (c) 2000 das buero am draht gmbh mfx\@dasburo.com **/ &nbsp; </td>
</tr>
</table>

EOF

sub make_table {
	my ($offset, $w, $h) = @_;

	my $acc = "";
	foreach $j (0 .. $h-1){
		$acc .= "<tr>";
		foreach $i (0 .. $w-1){
			my $bg = ($i + $j) & 1 ? "#cccccc" : "#ffffff";
			
			my $n = $i + $j * $w + $offset;
			my $nh = sprintf("%02x", $n);
			my $ch = chr($n);
			if($n >= 256){
				$ch = "";
			}
			$acc .= "<td bgcolor=$bg width=4% align=center><b>&#$n;&nbsp;<br>$ch</b>&nbsp;</td>";
			$acc .= "<td bgcolor=$bg width=3% align=right><small>\U$n<br>$nh</small></td>";
		}
		$acc .= "</tr>\n";
	}
	return $acc;
}
