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;
62 for (
$i = 0,
$c = strlen($string);
$i <
$c;
$i++) {
63 if ($string[
$i] !==
'%' && !isset($this->preserve[
$int = ord($string[
$i])])) {
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])) {
104 $encoding = strtoupper($encoding);
__construct($preserve=false)
String of characters that should be preserved while using encode().
Class that handles operations involving percent-encoding in URIs.
$preserve
Reserved characters to preserve when using encode().
encode($string)
Our replacement for urlencode, it encodes all non-reserved characters, as well as any extra character...
normalize($string)
Fix up percent-encoding by decoding unreserved characters and normalizing.