<?php
/*
*** The Funny Turnaround Class ***
*** The geeky, freaky, funny turnaround class ***
Jan. 27 - 2009 by Mirko Mönninghoff
JUST FOR FUN - AND OF COURSE: BSD-Licence
If you use it: Drop me a mail with your link:
Thanks 4 your time
UTF-8 is required !!!
*/
class turntext{
var $result = false;
var $table = array(
// Please correct if you find better fitting letters somewhere in the depth of unicode
//
// Original => Unicode
"0" => "48",
"1" => "124",
"2" => "645",
"3" => "603",
"6" => "54",
"8" => "56",
"9" => "57",
"a" => "592",
"b" => "997",
"c" => "596",
"d" => "447",
"e" => "477",
"f" => "584",
"g" => "595",
"h" => "613",
"i" => "618",
"j" => "383",
"k" => "670",
"l" => "1503", //"1397",
"m" => "623",
"n" => "535",
"o" => "111",
"p" => "1281",
"q" => "629",
"r" => "633",
"s" => "115",
"t" => "647",
"u" => "1400",
"v" => "652",
"w" => "653",
"x" => "120",
"y" => "654",
"z" => "10573",
"A" => "591",
"C" => "389",
"D" => "5601",
"E" => "604",
"J" => "663",
"G" => "600",
"H" => "668",
"L" => "906",
"N" => "628",
"O" => "79",
"P" => "1280",
"Q" => "433",
"R" => "641",
"S" => "643",
"U" => "5198",
"V" => "581",
"X" => "88",
"!" => "1571",
"?" => "191",
);
function __construct($qs = false) {
//If the argument "help" is given the unicode list will be echoed to the browser. this needs a while
if (isset($qs['help'])){
$this->show_unicode();
}
}
private function show_unicode(){
// I used this function to make the translation table:
//called it, turned my display bottom to top and uses my eyes and another display for editing
echo "<style> b{font-size: 2em;} </style>";
for ($i = 1; $i <= 65535; $i++){
$c = "&#" . $i . ";";
echo "[$i <b>$c</b> ] ";
}
}
function translate($string){
$r = "";
$string = strrev(trim ($string));
for ($i = 0; $i <= strlen ($string); $i++){
// Translate
$c = $string[$i];
$cu = strtoupper($c);
$cl = strtolower($c);
if (isset ($this->table[$c])){
//perfect match:
$m = "&#" . $this->table[$c] . ";";
} else if (isset ($this->table[$cl])){
//lower case version?
$m = "&#" . $this->table[$cl] . ";";
} else if (isset ($this->table[$cu])){
//upper case?
$m = "&#" . $this->table[$cu] . ";";
} else {
// not found: no conversion:
$m = $c;
}
$r.=$m;
}
$this->result = $r;
return $this->result;
}
}
?>