#!/usr/local/bin/php
<?
// Generates a page listing *every* DEFINED character, grouped by codeblock.
// NOT DESIGNED TO BE USED FROM A BROWSER! This page creates a CACHED STATIC PAGE, which
// should be piped or redirected from STDOUT into a file; "./allchars2 > allchars2.php".
// It usually only needs running when the parser runs, so that's what calls this.
set_time_limit(0); // for some reason, this can take a while to run...
require_once("functions.phps");
?>
<html>
<head>
<? require("meta.phps"); ?>
<title>All Characters By Codeblock</title>
<link rel="stylesheet" href="style.css" type="text/css">
<script language="Javascript" src="inc.js"></script>
</head>

<body bgcolor="#eeddff" link="#0000ee" vlink="#0000ee" alink="#ff0000">

<h3><a href="index.php"><I>UniSearcher</I> Home</a></h3>

<P>Below is every single <I>defined</I> Unicode character, organized by their "code block," so you can see at a "quick" 
glance which ones your browser font doesn't support. (It takes a while to load; be patient.) They're not clickable 
themselves, but you can click the block number in the leftmost column to go to that block's first 256-character chart 
page (some blocks span many pages). Each character is displayed using its actual UTF-8 character code. I've also added, 
to every character which is a "combining form," a second character from the same code block. "Combiners" are only 
visible when they're appended to another, <I>compatible</I> character that isn't a space. Every combined character is 
displayed in red. See the <a href="help.php#comb">full "user manual"</a> for a better explanation of combining forms 
(and a great many other things). And every character has a space after it too, so word wrapping works in the right-most 
table column.<BR><BR>

This page can take quite a lot of time (and memory) for your browser to display it. It could bring your browser to its 
knees in fact, especially if you have "smooth scrolling" turned on and/or antialiasing of font graphics. Take care. </P>

<hr noshade size="1">

<table border="0" cellpadding="3" cellspacing="0">
  <tr bgcolor="#FFFFFF">
    <th align="left">Code Block</th>
    <th align="left">All Characters In Block</th>
<?
$BEGIN=GMT();
$allblocks=loadblocks();
$combiners=CombiningGlyphs();

// We only need the list of codepoints, in decimal. Everything else is extrapolated therefrom.
$sq="select deccode from codepoint order by deccode";
$res=dosql($sq);
if (!$res || mysql_num_rows($res) < 1) {
    echo "How could \"$sq\" have possibly failed??? And yet it did. So I die.";
    footer();
}

$TD=array();
while (list($dec)=mysql_fetch_row($res)) { // should only be 88,053 or so as of 10/17/2006.
    list($bs, $be, $bn)=CodepointToBlock(dechex($dec));
//    if ($combiners[$dec]) $TD[$bs] .= '<font color="#CC0000">.';
//    $TD[$bs] .= Codepoint2Utf8($dec);      
//    if ($combiners[$dec]) $TD[$bs] .= '</font>'; 
//    $TD[$bs] .= ' ';

    if ($combiners[$dec])  
        $TD[$bs] .= '<font color="#CC0000">' . CombinedChar(dechex($dec)) . '</font> ';
    else
        $TD[$bs] .= Codepoint2Utf8($dec) . ' ';
}

// Now display a <TR> for every $allblocks... try looping by those blocks.
//$prevblockstart = -1;
$i=0;
$rc1="#EEEEEE";
$rc2="#DDDDDD";
$hc1="#EEEEFF";
$hc2="#DDDDFF";
foreach ($allblocks as $B) {
    $blockstart=$B[0];
    if ($blockstart==-1) continue; // invalid block; there'll be ZERO characters in it.
    $blockend=$B[1];
    $blockname=$B[2];
    $blockstarthex=hexpad(dechex($blockstart));
    $blockendhex=hexpad(dechex($blockend));
    $blockspan=number_format($blockend-$blockstart+1);
    list($page, $subpage)=CodepointToPages($blockstarthex);
    $url="index.php?page=$page&subpage=$subpage";
    if (++$i % 2) {
        $c=$rc1;
        $hc=$hc1;
    } else {
        $c=$rc2;
        $hc=$hc2;
    }
    echo "</td>\n</tr>\n<tr bgcolor=\"$c\">\n" .
        "<th nowrap align=\"left\" valign=\"top\" bgcolor=\"$hc\">" .
          "$blockname<BR>" .
          "$blockspan Characters Allocated<BR>" .
          "<a href=\"$url\">0x$blockstarthex to 0x$blockendhex</a>" .
        "</th>\n<td class=\"char\" valign=\"top\">{$TD[$blockstart]}</td>\n</tr>\n";
}
$STOP=number_format(round(GMT()-$BEGIN, 2), 2);
echo "</td>\n</tr>\n</table>\n" . number_format(mysql_num_rows($res)) . " characters total; $STOP seconds generation time.";
footer();
?>
