Advertisement
heislertecreator

UnicodeTest2.php

Nov 25th, 2024
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.53 KB | None | 0 0
  1. <?php
  2.  
  3. $z = $_REQUEST['z'];
  4. if ($z == '') $z = "0";
  5.  
  6. $a = $_REQUEST['a'];
  7. if ($a == '') $a = "0";
  8.  
  9. $b = $_REQUEST['b'];
  10. if ($b == '') $b = "0";
  11.  
  12.  
  13. function decrementHex($hex) {
  14. if ($hex == "10") return "F";
  15. if ($hex == 0) return "F";
  16. if ($hex == 1) return "0";
  17. if ($hex == 2) return "1";
  18. if ($hex == 3) return "2";
  19. if ($hex == 4) return "3";
  20. if ($hex == 5) return "4";
  21. if ($hex == 6) return "5";
  22. if ($hex == 7) return "6";
  23. if ($hex == 8) return "7";
  24. if ($hex == 9) return "8";
  25. if ($hex == 10) return "9";
  26. if ($hex == 11) return "A";
  27. if ($hex == 12) return "B";
  28. if ($hex == 13) return "C";
  29. if ($hex == 14) return "D";
  30. if ($hex == 15) return "E";
  31. }
  32.  
  33. function incrementHex($hex) {
  34. if ($hex == 16) return "10";
  35. if ($hex == 0) return "1";
  36. if ($hex == 1) return "2";
  37. if ($hex == 2) return "3";
  38. if ($hex == 3) return "4";
  39. if ($hex == 4) return "5";
  40. if ($hex == 5) return "6";
  41. if ($hex == 6) return "7";
  42. if ($hex == 7) return "8";
  43. if ($hex == 8) return "9";
  44. if ($hex == 9) return "A";
  45. if ($hex == 10) return "B";
  46. if ($hex == 11) return "C";
  47. if ($hex == 12) return "D";
  48. if ($hex == 13) return "E";
  49. if ($hex == 14) return "F";
  50. if ($hex == 15) return "0";
  51. }
  52.  
  53. function toDecimal($hex) {
  54. if ($hex == "10") return 16;
  55. if ($hex == "F") return 15;
  56. if ($hex == "E") return 14;
  57. if ($hex == "D") return 13;
  58. if ($hex == "C") return 12;
  59. if ($hex == "B") return 11;
  60. if ($hex == "A") return 10;
  61. if ($hex == "9") return 9;
  62. if ($hex == "8") return 8;
  63. if ($hex == "7") return 7;
  64. if ($hex == "6") return 6;
  65. if ($hex == "5") return 5;
  66. if ($hex == "4") return 4;
  67. if ($hex == "3") return 3;
  68. if ($hex == "2") return 2;
  69. if ($hex == "1") return 1;
  70. if ($hex == "0") return 0;
  71. if ($hex == "") return 0;
  72. }
  73.  
  74. function toHex($i = "") {
  75. if ($i >= 0 && $i <= 9) return $i;
  76. if ($i == 10) return "A";
  77. if ($i == 11) return "B";
  78. if ($i == 12) return "C";
  79. if ($i == 13) return "D";
  80. if ($i == 14) return "E";
  81. if ($i == 15) return "F";
  82. if ($i == 16) return "10";
  83. }
  84.  
  85. function toUnicode($str = "") {
  86. return mb_chr($str);
  87. }
  88.  
  89. function getNext($target) {
  90. if ($target == "10") return 0;
  91. if ($target == "0") return "1";
  92. if ($target == "1") return "2";
  93. if ($target == "2") return "3";
  94. if ($target == "3") return "4";
  95. if ($target == "4") return "5";
  96. if ($target == "5") return "6";
  97. if ($target == "6") return "7";
  98. if ($target == "7") return "8";
  99. if ($target == "8") return "9";
  100. if ($target == "9") return "A";
  101. if ($target == "A") return "B";
  102. if ($target == "B") return "C";
  103. if ($target == "C") return "D";
  104. if ($target == "D") return "E";
  105. if ($target == "E") return "F";
  106. if ($target == "F") return "0";
  107. }
  108.  
  109. function getPrevious($target) {
  110. if ($target == "10") return "F";
  111. if ($target == "F") return "E";
  112. if ($target == "E") return "D";
  113. if ($target == "D") return "C";
  114. if ($target == "C") return "B";
  115. if ($target == "B") return "A";
  116. if ($target == "A") return "9";
  117. if ($target == "9") return "8";
  118. if ($target == "8") return "7";
  119. if ($target == "7") return "6";
  120. if ($target == "6") return "5";
  121. if ($target == "5") return "4";
  122. if ($target == "4") return "3";
  123. if ($target == "3") return "2";
  124. if ($target == "2") return "1";
  125. if ($target == "1") return "0";
  126. if ($target == "0") return "F";
  127. }
  128.  
  129. function decrement($z = "0", $a = "0", $b = "0") {
  130. $b = getPrevious($b);
  131. if ($b == "F") {
  132. $a = getPrevious($a);
  133. if ($a == "F") {
  134. if ($z == "0") {
  135. $z = "10";
  136. } else if ($z == "10") {
  137. $z = "F";
  138. } else {
  139. $z = getPrevious($z);
  140. }
  141. }
  142. }
  143. return "z=$z&a=$a&b=$b";
  144. }
  145.  
  146. function decrementA($z = "0", $a = "0", $b = "0") {
  147. $a = getPrevious($a);
  148. return "z=$z&a=$a&b=$b";
  149. }
  150.  
  151. function decrementB($z = "0", $a = "0", $b = "0") {
  152. $b = getPrevious($b);
  153. return "z=$z&a=$a&b=$b";
  154. }
  155.  
  156. function decrementZ($z = "0", $a = "0", $b = "0") {
  157. if ($z == "0") {
  158. $z = "10";
  159. } else if ($z == "10") {
  160. $z = "F";
  161. } else {
  162. $z = getPrevious($z);
  163. }
  164. return "z=$z&a=$a&b=$b";
  165. }
  166.  
  167. function increment($z = "0", $a = "0", $b = "0") {
  168. $b = getNext($b);
  169. if ($b == "0") {
  170. $a = getNext($a);
  171. if ($a == "0") {
  172. if ($z == "F") {
  173. $z = "10";
  174. } else if ($z == "10") {
  175. $z = "0";
  176. } else {
  177. $z = getNext($z);
  178. }
  179. }
  180. }
  181. return "z=$z&a=$a&b=$b";
  182. }
  183.  
  184. function incrementA($z = "0", $a = "0", $b = "0") {
  185. $a = getNext($a);
  186. return "z=$z&a=$a&b=$b";
  187. }
  188.  
  189. function incrementB($z = "0", $a = "0", $b = "0") {
  190. $b = getNext($b);
  191. return "z=$z&a=$a&b=$b";
  192. }
  193.  
  194. function incrementZ($z = "0", $a = "0", $b = "0") {
  195. if ($z == "F") {
  196. $z = "10";
  197. } else if ($z == "10") {
  198. $z = "0";
  199. } else {
  200. $z = getNext($z);
  201. }
  202. return "z=$z&a=$a&b=$b";
  203. }
  204.  
  205. ?>
  206. <?php
  207. $prev = "/ca/tecreations/UnicodeTest2.php?" . decrement($z, $a, $b);
  208. $next = "/ca/tecreations/UnicodeTest2.php?" . increment($z, $a, $b);
  209.  
  210. $Z = ""; // make it so the user can "get" it?
  211. $A = "";
  212. $B = "";
  213.  
  214.  
  215. print("Z: ");
  216. for($i = 0; $i < 16; $i++) {
  217. $link = "<a href='/ca/tecreations/UnicodeTest2.php?z=" . toHex($i) . "&a=$a&b=$b'>" . toHex($i) . "</a>";
  218. echo $link . "&nbsp;&nbsp;";
  219. }
  220. $link = "<a href='/ca/tecreations/UnicodeTest2.php?z=10&a=$a&b=$b'>10</a>";
  221. echo $link;
  222.  
  223. echo "<br />\n";
  224.  
  225. print("A: ");
  226. for($i = 0; $i < 16; $i++) {
  227. $link = "<a href='/ca/tecreations/UnicodeTest2.php?z=$z&a=" . toHex($i) . "&b=$b'>" . toHex($i) . "</a>";
  228. echo $link . "&nbsp;&nbsp;";
  229. }
  230. echo "<br />";
  231.  
  232. print("B: ");
  233. for($i = 0; $i < 16; $i++) {
  234. $link = "<a href='/ca/tecreations/UnicodeTest2.php?z=$z&a=$a&b=" . toHex($i) . "'>" . toHex($i) . "</a>";
  235. echo $link . "&nbsp;&nbsp;";
  236. }
  237. echo "<br />";
  238.  
  239. ?>
  240. <br />
  241. <a href="<?php echo $prev; ?>">Previous</a> ::
  242. <?php
  243. echo "<a href='/ca/tecreations/UnicodeTest2.php?" . decrementZ($z,$a,$b) . "'>Z</a>";
  244. ?>
  245. :
  246. <?php
  247. echo "<a href='/ca/tecreations/UnicodeTest2.php?" . decrementA($z,$a,$b) . "'>A</a>";
  248. ?>
  249. :
  250. <?php
  251. echo "<a href='/ca/tecreations/UnicodeTest2.php?" . decrementB($z,$a,$b) . "'>B</a>";
  252. ?>
  253.  
  254. -- <a href="<?php echo $next; ?>">Next</a> ::
  255. <?php
  256. echo "<a href='/ca/tecreations/UnicodeTest2.php?" . incrementZ($z,$a,$b) . "'>Z</a>";
  257. ?>
  258. :
  259. <?php
  260. echo "<a href='/ca/tecreations/UnicodeTest2.php?" . incrementA($z,$a,$b) . "'>A</a>";
  261. ?>
  262. :
  263. <?php
  264. echo "<a href='/ca/tecreations/UnicodeTest2.php?" . incrementB($z,$a,$b) . "'>B</a>";
  265. ?>
  266.  
  267. <br />
  268. <hr />
  269. <?php
  270.  
  271. $line = "";
  272. if ($z == "10") $zDec = 16 * 256 * 256;
  273. else $zDec = toDecimal($z) * 256 * 256;
  274. echo "$" . "zDec: $zDec<br />";
  275. echo "<hr />";
  276. for($c = 0; $c < 16; $c++) {
  277. $line = $c . ": ";
  278. for($d = 0; $d < 16; $d++) {
  279.  
  280. $line .= mb_chr( $zDec + ($a * 256 * 16) + ($b * 256) + ($c * 16) + $d, 'UTF-8') . " ";
  281. $line .= "
  282. }
  283. $line .= "<br /><br />\n";
  284. echo $line;
  285. }
  286. echo "<br />\n"; // space them at least 1 line apart each
  287. ?>
  288. <hr />
  289.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement