// // Papertape Convertor v1.0 by Edwin Groothuis (edwin@mavetju.org) // // $Id: papertape-demo.php,v 1.2 2003/03/15 07:46:31 mavetju Exp $ // // If you didn't get this file via http://www.mavetju.org, please // check for the availability of newer versions. // // See LICENSE for distribution issues. If this file isn't in // the distribution, please inform me about it. // // Feel free to use this yourself. // // // Usage: // // start_papertape() // to_papertape(...) // finish_papertape() // stop_papertape() // function start_papertape() { return "___________"; } function finish_papertape() { return "| o. o |"; } function stop_papertape() { return "___________"; } function to_papertape($char) { $ret="|"; $char=ord($char); for ($i=7;$i>=0;$i--) { if ($i==2) $ret.="."; // feed hole if (($char & (1<<$i)) !=0) $ret.="o"; else $ret.=" "; } $ret.="|"; return $ret; } if (isset($_REQUEST["text"])) { echo "
",start_papertape(),"\n"; $len=strlen($_REQUEST["text"]); for ($i=0;$i<$len;$i++) { $d=$_REQUEST["text"][$i]; echo "$d ",to_papertape($d),"\n"; } echo " ",finish_papertape(),"\n"; echo " ",stop_papertape(),"\n"; } else { $_REQUEST["text"]=""; } ?> Enter text