Posto la porzione di codice incriminata sperando in un vs aiuto.
Codice: Seleziona tutto
<?php
function named_to_numeric ($string) {
global $_entities;
$string = strtr($string, $_entities['latin']);
$string = strtr($string, $_entities['extended']);
return $string;
}
function normalize_numeric ($string) {
global $_entities;
$string = strtr($string, $_entities['cp1251']);
$string = preg_replace('/&#([0-9]+)/e', "'&#x'.dechex('\\1')", $string);
$string = preg_replace('/&#[Xx]([0-9A-Fa-f]+)(;?|([^A-Za-z0-9\;\:\.\-\_]))/', '&#x\\1;\\3', $string);
return $string;
}
function numeric_to_utf8 ($string) {
$string = preg_replace('/&#([0-9]+)/e', "'�'.dechex('\\1')", $string);
$string = preg_replace('/&#[Xx]([0-9A-Fa-f]+);/e', "_hex_to_utf8('\\1')", $string);
return $string;
}
function numeric_to_named ($string) {
global $_entities;
$string = preg_replace('/&#[Xx]([0-9A-Fa-f]+)/e', "'&#'.hexdec('\\1')", $string);
$string = strtr($string, array_flip($_entities['latin']));
$string = strtr($string, array_flip($_entities['extended']));
return $string;
}
function specialchars ($string, $type = 'xml') {
$apos = $type == 'xml' ? ''' : ''';
$specialchars = array (
'"' => '"', '&' => '&',
''' => $apos, '<' => '<',
'>' => '>', '"' => '"',
'&' => '&', "'" => $apos,
'<' => '<', '>' => '>'
);
$string = preg_replace('/&(#?[Xx]?[0-9A-Za-z]+);/', "[[[ENTITY:\\1]]]", $string);
$string = strtr($string, $specialchars);
$string = preg_replace('/\[\[\[ENTITY\:([^\]]+)\]\]\]/', "&\\1;", $string);
return $string;
}
function _hex_to_utf8($s)
{
/* IN: string containing one hexadecimal Unicode character
* OUT: string containing one binary UTF-8 character
*/
$c = hexdec($s);
if ($c < 0x80) {
$str = chr($c);
}
else if ($c < 0x800) {
$str = chr(0xC0 | $c>>6) . chr(0x80 | $c & 0x3F);
}
else if ($c < 0x10000) {
$str = chr(0xE0 | $c>>12) . chr(0x80 | $c>>6 & 0x3F) . chr(0x80 | $c & 0x3F);
}
else if ($c < 0x200000) {
$str = chr(0xF0 | $c>>18) . chr(0x80 | $c>>12 & 0x3F) . chr(0x80 | $c>>6 & 0x3F) . chr(0x80 | $c & 0x3F);
}
return $str;
}
$_entities['cp1251'] = array (
'€' => '€', '‚' => '‚', 'ƒ' => 'ƒ',
'„' => '„', '…' => '…', '†' => '†',
'‡' => '‡', 'ˆ' => 'ˆ', '‰' => '‰',
'Š' => 'Š', '‹' => '‹', 'Œ' => 'Œ',
'Ž' => 'Ž', '‘' => '‘', '’' => '’',
'“' => '“', '”' => '”', '•' => '•',
'–' => '–', '—' => '—', '˜' => '˜',
'™' => '™', 'š' => 'š', '›' => '›',
'œ' => 'œ', 'ž' => 'ž', 'Ÿ' => 'Ÿ',
);
$_entities['latin'] = array (
' ' => ' ', '¡' => '¡', '¢' => '¢',
'£' => '£', '¤' => '¤', '¥' => '¥',
'¦' => '¦', '§' => '§', '¨' => '¨',
'©' => '©', 'ª' => 'ª', '«' => '«',
'¬' => '¬', '­' => '­', '®' => '®',
'¯' => '¯', '°' => '°', '±' => '±',
'²' => '²', '³' => '³', '´' => '´',
'µ' => 'µ', '¶' => '¶', '·' => '·',
'¸' => '¸', '¹' => '¹', 'º' => 'º',
'»' => '»', '¼' => '¼', '½' => '½',
'¾' => '¾', '¿' => '¿', 'À' => 'À',
'Á' => 'Á', 'Â' => 'Â', 'Ã' => 'Ã',
'Ä' => 'Ä', 'Å' => 'Å', 'Æ' => 'Æ',
'Ç' => 'Ç', 'È' => 'È', 'É' => 'É',
'Ê' => 'Ê', 'Ë' => 'Ë', 'Ì' => 'Ì',
'Í' => 'Í', 'Î' => 'Î', 'Ï' => 'Ï',
'Ð' => 'Ð', 'Ñ' => 'Ñ', 'Ò' => 'Ò',
'Ó' => 'Ó', 'Ô' => 'Ô', 'Õ' => 'Õ',
'Ö' => 'Ö', '×' => '×', 'Ø' => 'Ø',
'Ù' => 'Ù', 'Ú' => 'Ú', 'Û' => 'Û',
'Ü' => 'Ü', 'Ý' => 'Ý', 'Þ' => 'Þ',
'ß' => 'ß', 'à' => 'à', 'á' => 'á',
'â' => 'â', 'ã' => 'ã', 'ä' => 'ä',
'å' => 'å', 'æ' => 'æ', 'ç' => 'ç',
'è' => 'è', 'é' => 'é', 'ê' => 'ê',
'ë' => 'ë', 'ì' => 'ì', 'í' => 'í',
'î' => 'î', 'ï' => 'ï', 'ð' => 'ð',
'ñ' => 'ñ', 'ò' => 'ò', 'ó' => 'ó',
'ô' => 'ô', 'õ' => 'õ', 'ö' => 'ö',
'÷' => '÷', 'ø' => 'ø', 'ù' => 'ù',
'ú' => 'ú', 'û' => 'û', 'ü' => 'ü',
'ý' => 'ý', 'þ' => 'þ', 'ÿ' => 'ÿ',
);
$_entities['extended'] = array (
'&OElig' => 'Œ', '&oelig' => 'å', '&Scaron' => 'Š',
'&scaron' => 'š', '&Yuml' => 'Ÿ', '&circ' => 'ˆ',
'&tilde' => '˜', '&esnp' => ' ', '&emsp' => ' ',
'&thinsp' => ' ', '&zwnj' => '‌', '&zwj' => '‍',
'&lrm' => '‎', '&rlm' => '‏', '&ndash' => '–',
'&mdash' => '—', '&lsquo' => '‘', '&rsquo' => '’',
'&sbquo' => '‚', '&ldquo' => '“', '&rdquo' => '”',
'&bdquo' => '„', '&dagger' => '†', '&Dagger' => '‡',
'&permil' => '‰', '&lsaquo' => '‹', '&rsaquo' => '›',
'&euro' => '€', '&fnof' => 'ƒ', '&Alpha' => 'Α',
'&Beta' => 'Β', '&Gamma' => 'Γ', '&Delta' => 'Δ',
'&Epsilon' => 'Ε', '&Zeta' => 'Ζ', '&Eta' => 'Η',
'&Theta' => 'Θ', '&Iota' => 'Ι', '&Kappa' => 'Κ',
'&Lambda' => 'Λ', '&Mu' => 'Μ', '&Nu' => 'Ν',
'&Xi' => 'Ξ', '&Omicron' => 'Ο', '&Pi' => 'Π',
'&Rho' => 'Ρ', '&Sigma' => 'Σ', '&Tau' => 'Τ',
'&Upsilon' => 'Υ', '&Phi' => 'Φ', '&Chi' => 'Χ',
'&Psi' => 'Ψ', '&Omega' => 'Ω', '&alpha' => 'α',
'&beta' => 'β', '&gamma' => 'γ', '&delta' => 'δ',
'&epsilon' => 'ε', '&zeta' => 'ζ', '&eta' => 'η',
'&theta' => 'θ', '&iota' => 'ι', '&kappa' => 'κ',
'&lambda' => 'λ', '&mu' => 'μ', '&nu' => 'ν',
'&xi' => 'ξ', '&omicron' => 'ο', '&pi' => 'π',
'&rho' => 'ρ', '&sigmaf' => 'ς', '&sigma' => 'σ',
'&tau' => 'τ', '&upsilon' => 'υ', '&phi' => 'φ',
'&chi' => 'χ', '&psi' => 'ψ', '&omega' => 'ω',
'&thetasym' => 'ϑ', '&upsih' => 'ϒ', '&piv' => 'ϖ',
'&bull' => '•', '&hellip' => '…', '&prime' => '′',
'&Prime' => '″', '&oline' => '‾', '&frasl' => '⁄',
'&weierp' => '℘', '&image' => 'ℑ', '&real' => 'ℜ',
'&trade' => '™', '&alefsym' => 'ℵ', '&larr' => '←',
'&uarr' => '↑', '&rarr' => '→', '&darr' => '↓',
'&harr' => '↔', '&crarr' => '↵', '&lArr' => '⇐',
'&uArr' => '⇑', '&rArr' => '⇒', '&dArr' => '⇓',
'&hArr' => '⇔', '&forall' => '∀', '&part' => '∂',
'&exist' => '∃', '&empty' => '∅', '&nabla' => '∇',
'&isin' => '∈', '¬in' => '∉', '&ni' => '∋',
'&prod' => '∏', '&sum' => '∑', '&minus' => '−',
'&lowast' => '∗', '&radic' => '√', '&prop' => '∝',
'&infin' => '∞', '&ang' => '∠', '&and' => '∧',
'&or' => '∨', '&cap' => '∩', '&cup' => '∪',
'&int' => '∫', '&there4' => '∴', '&sim' => '∼',
'&cong' => '≅', '&asymp' => '≈', '&ne' => '≠',
'&equiv' => '≡', '&le' => '≤', '&ge' => '≥',
'&sub' => '⊂', '&sup' => '⊃', '&nsub' => '⊄',
'&sube' => '⊆', '&supe' => '⊇', '&oplus' => '⊕',
'&otimes' => '⊗', '&perp' => '⊥', '&sdot' => '⋅',
'&lceil' => '⌈', '&rceil' => '⌉', '&lfloor' => '⌊',
'&rfloor' => '⌋', '&lang' => '〈', '&rang' => '〉',
'&loz' => '◊', '&spades' => '♠', '&clubs' => '♣',
'&hearts' => '♥', '&diams' => '♦',
);
?>