24 for (
$i = 48;
$i <= 57;
$i++) $this->preserve[
$i] =
true;
25 for (
$i = 65;
$i <= 90;
$i++) $this->preserve[
$i] =
true;
26 for (
$i = 97;
$i <= 122;
$i++) $this->preserve[
$i] =
true;
27 $this->preserve[45] =
true;
28 $this->preserve[46] =
true;
29 $this->preserve[95] =
true;
30 $this->preserve[126]=
true;
52 for (
$i = 0, $c = strlen($string);
$i < $c;
$i++) {
53 if ($string[
$i] !==
'%' && !isset($this->preserve[$int = ord($string[
$i])]) ) {
54 $ret .=
'%' . sprintf(
'%02X', $int);
70 if ($string ==
'')
return '';
71 $parts = explode(
'%', $string);
72 $ret = array_shift($parts);
73 foreach ($parts as $part) {
74 $length = strlen($part);
76 $ret .=
'%25' . $part;
79 $encoding = substr($part, 0, 2);
80 $text = substr($part, 2);
81 if (!ctype_xdigit($encoding)) {
82 $ret .=
'%25' . $part;
85 $int = hexdec($encoding);
86 if (isset($this->preserve[$int])) {
87 $ret .= chr($int) . $text;
90 $encoding = strtoupper($encoding);
91 $ret .=
'%' . $encoding . $text;