#!/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; "./allchars1 > allchars1.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 Codepoint</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 Codepoints, 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 Defined Characters In Block</th>
<?
$BEGIN=GMT();
$allblocks=loadblocks();

// 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();
}

// Now display a <TR> for every $allblocks... but don't loop it BY allblocks, loop by characters.
$prevblockstart = -1;
$i=0;
$rc1="#EEEEEE";
$rc2="#DDDDDD";
$hc1="#EEEEFF";
$hc2="#DDDDFF";
$combiners=CombiningGlyphs();
while (list($dec)=mysql_fetch_row($res)) { // should only be 88,053 as of 10/17/2006.
    $hex=dechex($dec); // don't hexpad this one; no need yet.
    list($blockstart, $blockend, $blockname)=CodepointToBlock($hex); // for the name, mostly
    if ($blockstart==-1) continue; // invalid block; there'll be ZERO characters in it.
    if ($blockstart != $prevblockstart) {
        $blockstarthex=hexpad(dechex($blockstart));
        $blockendhex=hexpad(dechex($blockend));
        $blockspan=number_format($blockend-$blockstart+1);
        list($page, $subpage)=CodepointToPages($hex);
        $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\">";
        $prevblockstart=$blockstart;
    }
//    if (in_array($dec, $combiners)) echo '.';
    
    if ($combiners[$dec])
        echo '<font color="#CC0000">' . CombinedChar($hex) . '</font> ';
    else
        echo Codepoint2Utf8($dec) . ' ';
}
$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();
?>
