Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $z = $_REQUEST['z'];
- if ($z == '') $z = "0";
- $a = $_REQUEST['a'];
- if ($a == '') $a = "0";
- $b = $_REQUEST['b'];
- if ($b == '') $b = "0";
- function decrementHex($hex) {
- if ($hex == "10") return "F";
- if ($hex == 0) return "F";
- if ($hex == 1) return "0";
- if ($hex == 2) return "1";
- if ($hex == 3) return "2";
- if ($hex == 4) return "3";
- if ($hex == 5) return "4";
- if ($hex == 6) return "5";
- if ($hex == 7) return "6";
- if ($hex == 8) return "7";
- if ($hex == 9) return "8";
- if ($hex == 10) return "9";
- if ($hex == 11) return "A";
- if ($hex == 12) return "B";
- if ($hex == 13) return "C";
- if ($hex == 14) return "D";
- if ($hex == 15) return "E";
- }
- function incrementHex($hex) {
- if ($hex == 16) return "10";
- if ($hex == 0) return "1";
- if ($hex == 1) return "2";
- if ($hex == 2) return "3";
- if ($hex == 3) return "4";
- if ($hex == 4) return "5";
- if ($hex == 5) return "6";
- if ($hex == 6) return "7";
- if ($hex == 7) return "8";
- if ($hex == 8) return "9";
- if ($hex == 9) return "A";
- if ($hex == 10) return "B";
- if ($hex == 11) return "C";
- if ($hex == 12) return "D";
- if ($hex == 13) return "E";
- if ($hex == 14) return "F";
- if ($hex == 15) return "0";
- }
- function toDecimal($hex) {
- if ($hex == "10") return 16;
- if ($hex == "F") return 15;
- if ($hex == "E") return 14;
- if ($hex == "D") return 13;
- if ($hex == "C") return 12;
- if ($hex == "B") return 11;
- if ($hex == "A") return 10;
- if ($hex == "9") return 9;
- if ($hex == "8") return 8;
- if ($hex == "7") return 7;
- if ($hex == "6") return 6;
- if ($hex == "5") return 5;
- if ($hex == "4") return 4;
- if ($hex == "3") return 3;
- if ($hex == "2") return 2;
- if ($hex == "1") return 1;
- if ($hex == "0") return 0;
- if ($hex == "") return 0;
- }
- function toHex($i = "") {
- if ($i >= 0 && $i <= 9) return $i;
- if ($i == 10) return "A";
- if ($i == 11) return "B";
- if ($i == 12) return "C";
- if ($i == 13) return "D";
- if ($i == 14) return "E";
- if ($i == 15) return "F";
- if ($i == 16) return "10";
- }
- function toUnicode($str = "") {
- return mb_chr($str);
- }
- function getNext($target) {
- if ($target == "10") return 0;
- if ($target == "0") return "1";
- if ($target == "1") return "2";
- if ($target == "2") return "3";
- if ($target == "3") return "4";
- if ($target == "4") return "5";
- if ($target == "5") return "6";
- if ($target == "6") return "7";
- if ($target == "7") return "8";
- if ($target == "8") return "9";
- if ($target == "9") return "A";
- if ($target == "A") return "B";
- if ($target == "B") return "C";
- if ($target == "C") return "D";
- if ($target == "D") return "E";
- if ($target == "E") return "F";
- if ($target == "F") return "0";
- }
- function getPrevious($target) {
- if ($target == "10") return "F";
- if ($target == "F") return "E";
- if ($target == "E") return "D";
- if ($target == "D") return "C";
- if ($target == "C") return "B";
- if ($target == "B") return "A";
- if ($target == "A") return "9";
- if ($target == "9") return "8";
- if ($target == "8") return "7";
- if ($target == "7") return "6";
- if ($target == "6") return "5";
- if ($target == "5") return "4";
- if ($target == "4") return "3";
- if ($target == "3") return "2";
- if ($target == "2") return "1";
- if ($target == "1") return "0";
- if ($target == "0") return "F";
- }
- function decrement($z = "0", $a = "0", $b = "0") {
- $b = getPrevious($b);
- if ($b == "F") {
- $a = getPrevious($a);
- if ($a == "F") {
- if ($z == "0") {
- $z = "10";
- } else if ($z == "10") {
- $z = "F";
- } else {
- $z = getPrevious($z);
- }
- }
- }
- return "z=$z&a=$a&b=$b";
- }
- function decrementA($z = "0", $a = "0", $b = "0") {
- $a = getPrevious($a);
- return "z=$z&a=$a&b=$b";
- }
- function decrementB($z = "0", $a = "0", $b = "0") {
- $b = getPrevious($b);
- return "z=$z&a=$a&b=$b";
- }
- function decrementZ($z = "0", $a = "0", $b = "0") {
- if ($z == "0") {
- $z = "10";
- } else if ($z == "10") {
- $z = "F";
- } else {
- $z = getPrevious($z);
- }
- return "z=$z&a=$a&b=$b";
- }
- function increment($z = "0", $a = "0", $b = "0") {
- $b = getNext($b);
- if ($b == "0") {
- $a = getNext($a);
- if ($a == "0") {
- if ($z == "F") {
- $z = "10";
- } else if ($z == "10") {
- $z = "0";
- } else {
- $z = getNext($z);
- }
- }
- }
- return "z=$z&a=$a&b=$b";
- }
- function incrementA($z = "0", $a = "0", $b = "0") {
- $a = getNext($a);
- return "z=$z&a=$a&b=$b";
- }
- function incrementB($z = "0", $a = "0", $b = "0") {
- $b = getNext($b);
- return "z=$z&a=$a&b=$b";
- }
- function incrementZ($z = "0", $a = "0", $b = "0") {
- if ($z == "F") {
- $z = "10";
- } else if ($z == "10") {
- $z = "0";
- } else {
- $z = getNext($z);
- }
- return "z=$z&a=$a&b=$b";
- }
- ?>
- <?php
- $prev = "/ca/tecreations/UnicodeTest2.php?" . decrement($z, $a, $b);
- $next = "/ca/tecreations/UnicodeTest2.php?" . increment($z, $a, $b);
- $Z = ""; // make it so the user can "get" it?
- $A = "";
- $B = "";
- print("Z: ");
- for($i = 0; $i < 16; $i++) {
- $link = "<a href='/ca/tecreations/UnicodeTest2.php?z=" . toHex($i) . "&a=$a&b=$b'>" . toHex($i) . "</a>";
- echo $link . " ";
- }
- $link = "<a href='/ca/tecreations/UnicodeTest2.php?z=10&a=$a&b=$b'>10</a>";
- echo $link;
- echo "<br />\n";
- print("A: ");
- for($i = 0; $i < 16; $i++) {
- $link = "<a href='/ca/tecreations/UnicodeTest2.php?z=$z&a=" . toHex($i) . "&b=$b'>" . toHex($i) . "</a>";
- echo $link . " ";
- }
- echo "<br />";
- print("B: ");
- for($i = 0; $i < 16; $i++) {
- $link = "<a href='/ca/tecreations/UnicodeTest2.php?z=$z&a=$a&b=" . toHex($i) . "'>" . toHex($i) . "</a>";
- echo $link . " ";
- }
- echo "<br />";
- ?>
- <br />
- <a href="<?php echo $prev; ?>">Previous</a> ::
- <?php
- echo "<a href='/ca/tecreations/UnicodeTest2.php?" . decrementZ($z,$a,$b) . "'>Z</a>";
- ?>
- :
- <?php
- echo "<a href='/ca/tecreations/UnicodeTest2.php?" . decrementA($z,$a,$b) . "'>A</a>";
- ?>
- :
- <?php
- echo "<a href='/ca/tecreations/UnicodeTest2.php?" . decrementB($z,$a,$b) . "'>B</a>";
- ?>
- -- <a href="<?php echo $next; ?>">Next</a> ::
- <?php
- echo "<a href='/ca/tecreations/UnicodeTest2.php?" . incrementZ($z,$a,$b) . "'>Z</a>";
- ?>
- :
- <?php
- echo "<a href='/ca/tecreations/UnicodeTest2.php?" . incrementA($z,$a,$b) . "'>A</a>";
- ?>
- :
- <?php
- echo "<a href='/ca/tecreations/UnicodeTest2.php?" . incrementB($z,$a,$b) . "'>B</a>";
- ?>
- <br />
- <hr />
- <?php
- $line = "";
- if ($z == "10") $zDec = 16 * 256 * 256;
- else $zDec = toDecimal($z) * 256 * 256;
- echo "$" . "zDec: $zDec<br />";
- echo "<hr />";
- for($c = 0; $c < 16; $c++) {
- $line = $c . ": ";
- for($d = 0; $d < 16; $d++) {
- $line .= mb_chr( $zDec + ($a * 256 * 16) + ($b * 256) + ($c * 16) + $d, 'UTF-8') . " ";
- $line .= "
- }
- $line .= "<br /><br />\n";
- echo $line;
- }
- echo "<br />\n"; // space them at least 1 line apart each
- ?>
- <hr />
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement