Преобразование escape кодов вида "&code;" в символы.
Ключевые слова: (найти похожие документы)
Date: Mon, 30 Apr 2001 11:21:33 +0400
From: Tarasov Sergej <tarasov@pmi.lv>
Newsgroups: fido7.ru.perl
Subject: Преобразование escape кодов вида "&code;" в символы.
sub esc2char {
my ($esc) = @_;
my $char = " ";
if ($esc =~ /&[a-zA-Z]*;/) { $char = $html_esc{$esc} }
elsif ($esc =~ /&x([0-9]{1,3});/) { $char = chr($1) }
return $char;
}
%html_esc = (
"À" => chr(192),
"Á" => chr(193),
"Â" => chr(194),
"Ã" => chr(195),
"Ä" => chr(196),
"Å" => chr(197),
"Æ" => chr(198),
"Ç" => chr(199),
"È" => chr(200),
"É" => chr(201),
"&Eirc;" => chr(202),
"Ë" => chr(203),
"Ì" => chr(204),
"Í" => chr(205),
"Î" => chr(206),
"Ï" => chr(207),
"Ð" => chr(208),
"Ñ" => chr(209),
"Ò" => chr(210),
"Ó" => chr(211),
"Ô" => chr(212),
"Õ" => chr(213),
"Ö" => chr(214),
"×" => chr(215),
"Ø" => chr(216),
"Ù" => chr(217),
"Ú" => chr(218),
"Û" => chr(219),
"Ü" => chr(220),
"Ý" => chr(221),
"Þ" => chr(222),
"ß" => chr(223),
"à" => chr(224),
"á" => chr(225),
"â" => chr(226),
"ã" => chr(227),
"ä" => chr(228),
"å" => chr(229),
"æ" => chr(230),
"ç" => chr(231),
"è" => chr(232),
"é" => chr(233),
"ê" => chr(234),
"ë" => chr(235),
"ì" => chr(236),
"í" => chr(237),
"î" => chr(238),
"ï" => chr(239),
"ð" => chr(240),
"ñ" => chr(241),
"ò" => chr(242),
"ó" => chr(243),
"ô" => chr(244),
"õ" => chr(245),
"ö" => chr(246),
"÷" => chr(247),
"ø" => chr(248),
"ù" => chr(249),
"ú" => chr(250),
"û" => chr(251),
"ü" => chr(252),
"ý" => chr(253),
"þ" => chr(254),
"ÿ" => chr(255),
" " => " ",
"&" => " ",
""e;" => " ",
);