27 for ($i = 48; $i <= 57; $i++) {
28 $this->preserve[$i] =
true;
30 for ($i = 65; $i <= 90; $i++) {
31 $this->preserve[$i] =
true;
33 for ($i = 97; $i <= 122; $i++) {
34 $this->preserve[$i] =
true;
36 $this->preserve[45] =
true;
37 $this->preserve[46] =
true;
38 $this->preserve[95] =
true;
39 $this->preserve[126]=
true;
43 for ($i = 0, $c = strlen(
$preserve); $i < $c; $i++) {
44 $this->preserve[ord(
$preserve[$i])] =
true;
62 for ($i = 0, $c = strlen($string); $i < $c; $i++) {
63 if ($string[$i] !==
'%' && !isset($this->preserve[$int = ord($string[$i])])) {
64 $ret .=
'%' . sprintf(
'%02X', $int);
85 $parts = explode(
'%', $string);
86 $ret = array_shift($parts);
87 foreach ($parts as $part) {
88 $length = strlen($part);
90 $ret .=
'%25' . $part;
93 $encoding = substr($part, 0, 2);
94 $text = substr($part, 2);
95 if (!ctype_xdigit($encoding)) {
96 $ret .=
'%25' . $part;
99 $int = hexdec($encoding);
100 if (isset($this->preserve[$int])) {
101 $ret .= chr($int) . $text;
104 $encoding = strtoupper($encoding);
105 $ret .=
'%' . $encoding . $text;