@@ 22-39 (lines=18) @@ | ||
19 | *@internal note pack(�C�,hexdec(substr($data,$i,2))) DOES NOT WORK |
|
20 | * |
|
21 | **/ |
|
22 | function decode($data) { |
|
23 | ||
24 | $hexString=$data; |
|
25 | $BinStr = ''; |
|
26 | ||
27 | $hexLength=strlen($hexString); |
|
28 | // only hex numbers is allowed |
|
29 | if ($hexLength % 2 != 0 || preg_match("/[^\da-fA-F]/",$hexString)) return FALSE; |
|
30 | ||
31 | ||
32 | //Loop through the input and convert it |
|
33 | for ($i = 0; $i < $hexLength; $i += 2) |
|
34 | $BinStr .= '%'.substr ($hexString, $i, 2); |
|
35 | ||
36 | ||
37 | // Raw url-decode and return the result |
|
38 | return rawurldecode ($BinStr);//chr(hexdec()) |
|
39 | } |
|
40 | ||
41 | ||
42 | /** |
@@ 1035-1052 (lines=18) @@ | ||
1032 | *@param string $hexString the hexified string |
|
1033 | *@return string $bin a binary string |
|
1034 | **/ |
|
1035 | function _hex2bin ($hexString) |
|
1036 | { |
|
1037 | //echo "<br>_hex2bin($hexString)"; |
|
1038 | $BinStr = ''; |
|
1039 | ||
1040 | $hexLength=strlen($hexString); |
|
1041 | // only hex numbers is allowed |
|
1042 | if ($hexLength % 2 != 0 || preg_match("/[^\da-fA-F]/",$hexString)) return FALSE; |
|
1043 | ||
1044 | ||
1045 | //Loop through the input and convert it |
|
1046 | for ($i = 0; $i < $hexLength; $i += 2) |
|
1047 | $BinStr .= '%'.substr ($hexString, $i, 2); |
|
1048 | ||
1049 | ||
1050 | // Raw url-decode and return the result |
|
1051 | return rawurldecode ($BinStr);//chr(hexdec()) |
|
1052 | } |
|
1053 | ||
1054 | ||
1055 | /** |