- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
class location {
private $url;
function __construct($url) {
$this->url = $url;
$this->ruDecode();
}
private function ruIeConv($m) {
$a1 = base_convert($m[1], 16, 10);
$a2 = base_convert($m[2], 16, 10);
# мальнькие буквы
if($a1 == 208 && $a2 >= 176 && $a2 <= 191) return chr($a2+48);
if($a1 == 209 && $a2 >= 128 && $a2 <= 143) return chr($a2+112);
if($a1 == 209 && $a2 == 145) return 'ё';
# большие
if($a1 == 208 && $a2 >= 144 && $a2 <= 175) return chr($a2+48);
if($a1 == 208 && $a2 == 129) return 'Ё';
return $m[0];
}
private function ruFfConv($m) {
return chr(base_convert($m[1], 16, 10));
}
private function ruDecode() {
$this->url = str_replace('%20', ' ', $this->url);
$this->url = preg_replace_callback('~%(D[01])%([0-9A-F]{2})~i', array($this, 'ruIeConv'), $this->url);
$this->url = preg_replace_callback('~%([A-F][A-F0-9])~i', array($this, 'ruFfConv'), $this->url);
}
function __toString() {
return $this->url;
}
}
echo new location('%D1%82%D0%B5%D0%B3%D0%B8'); // теги (windows-1251)
guest 06.07.2011 00:30 # +3
striker 06.07.2011 03:39 # 0
guest 06.07.2011 10:46 # 0
Lure Of Chaos 07.07.2011 17:22 # 0
MoLe-X 06.07.2011 07:55 # +1
Vasiliy 06.07.2011 08:23 # +1