Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Converts all entities of the XHTML Transitional's DTD in Unicode.
- * DTD Section:
- * <code>
- * <!--================ Character mnemonic entities =========================-->
- *
- * <!ENTITY % HTMLlat1 PUBLIC
- * "-//W3C//ENTITIES Latin 1 for XHTML//EN"
- * "xhtml-lat1.ent">
- * %HTMLlat1;
- *
- * <!ENTITY % HTMLsymbol PUBLIC
- * "-//W3C//ENTITIES Symbols for XHTML//EN"
- * "xhtml-symbol.ent">
- * %HTMLsymbol;
- *
- * <!ENTITY % HTMLspecial PUBLIC
- * "-//W3C//ENTITIES Special for XHTML//EN"
- * "xhtml-special.ent">
- * %HTMLspecial;
- * </code>
- * @author G. Qyy
- * @copyright Copyright (c) 2010 G. Qyy
- * @license http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
- * @link http://stackoverflow.com/q/4081090/492638
- * @link http://blog.qyy.fr/2010/10/convertir-des-entites-xhtml-en-unicode.html
- * @link http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd
- * @link http://www.w3.org/TR/xhtml1/DTD/xhtml-lat1.ent
- * @link http://www.w3.org/TR/xhtml1/DTD/xhtml-symbol.ent
- * @link http://www.w3.org/TR/xhtml1/DTD/xhtml-special.ent
- * @param string $string <p>
- * A string containing entities declared in the XHTML Transitional's DTD
- * </p>
- * @return string The provided string with all XHTML Transitional's
- * entities converted to Unicode entities.
- */
- function ConvertEntitiesToUnicode($string)
- {
- $unicode = array(
- '"','&','<','>',''','Œ','œ','Š',
- 'š','Ÿ','ˆ','˜',' ',' ',' ',
- '‌','‍','‎','‏','–','—','‘',
- '’','‚','“','”','„','†','‡',
- '‰','‹','›','€',' ','¡','¢',
- '£','¤','¥','¦','§','¨','©','ª',
- '«','¬','­','®','¯','°','±','²',
- '³','´','µ','¶','·','¸','¹','º',
- '»','¼','½','¾','¿','À','Á','Â',
- 'Ã','Ä','Å','Æ','Ç','È','É','Ê',
- 'Ë','Ì','Í','Î','Ï','Ð','Ñ','Ò',
- 'Ó','Ô','Õ','Ö','×','Ø','Ù','Ú',
- 'Û','Ü','Ý','Þ','ß','à','á','â',
- 'ã','ä','å','æ','ç','è','é','ê',
- 'ë','ì','í','î','ï','ð','ñ','ò',
- 'ó','ô','õ','ö','÷','ø','ù','ú',
- 'û','ü','ý','þ','ÿ','ƒ','Α','Β',
- 'Γ','Δ','Ε','Ζ','Η','Θ','Ι','Κ',
- 'Λ','Μ','Ν','Ξ','Ο','Π','Ρ','Σ',
- 'Τ','Υ','Φ','Χ','Ψ','Ω','α','β',
- 'γ','δ','ε','ζ','η','θ','ι','κ',
- 'λ','μ','ν','ξ','ο','π','ρ','ς',
- 'σ','τ','υ','φ','χ','ψ','ω','ϑ',
- 'ϒ','ϖ','•','…','′','″','‾',
- '⁄','℘','ℑ','ℜ','™','ℵ','←',
- '↑','→','↓','↔','↵','⇐','⇑',
- '⇒','⇓','⇔','∀','∂','∃','∅',
- '∇','∈','∉','∋','∏','∑','−',
- '∗','√','∝','∞','∠','∧','∨',
- '∩','∪','∫','∴','∼','≅','≈',
- '≠','≡','≤','≥','⊂','⊃','⊄',
- '⊆','⊇','⊕','⊗','⊥','⋅','⌈',
- '⌉','⌊','⌋','〈','〉','◊','♠',
- '♣','♥','♦'
- );
- $entities = array(
- '"','&','<','>',''','Œ','œ','Š',
- 'š','Ÿ','ˆ','˜',' ',' ',' ',
- '‌','‍','‎','‏','–','—','‘','’',
- '‚','“','”','„','†','‡','‰',
- '‹','›','€',' ','¡','¢','£',
- '¤','¥','¦','§','¨','©','ª',
- '«','¬','­','®','¯','°','±','²',
- '³','´','µ','¶','·','¸','¹',
- 'º','»','¼','½','¾','¿','À',
- 'Á','Â','Ã','Ä','Å','Æ','Ç',
- 'È','É','Ê','Ë','Ì','Í','Î',
- 'Ï','Ð','Ñ','Ò','Ó','Ô','Õ',
- 'Ö','×','Ø','Ù','Ú','Û','Ü',
- 'Ý','Þ','ß','à','á','â','ã',
- 'ä','å','æ','ç','è','é','ê',
- 'ë','ì','í','î','ï','ð','ñ',
- 'ò','ó','ô','õ','ö','÷','ø',
- 'ù','ú','û','ü','ý','þ','ÿ',
- 'ƒ','Α','Β','Γ','Δ','Ε','Ζ',
- 'Η','Θ','Ι','Κ','Λ','Μ','Ν','Ξ',
- 'Ο','Π','Ρ','Σ','Τ','Υ','Φ','Χ',
- 'Ψ','Ω','α','β','γ','δ','ε',
- 'ζ','η','θ','ι','κ','λ','μ','ν',
- 'ξ','ο','π','ρ','ς','σ','τ',
- 'υ','φ','χ','ψ','ω','ϑ','ϒ',
- 'ϖ','•','…','′','″','‾','⁄',
- '℘','ℑ','ℜ','™','ℵ','←','↑',
- '→','↓','↔','↵','⇐','⇑','⇒','⇓',
- '⇔','∀','∂','∃','∅','∇','∈',
- '∉','∋','∏','∑','−','∗','√','∝',
- '∞','∠','∧','∨','∩','∪','∫','∴',
- '∼','≅','≈','≠','≡','≤','≥','⊂','⊃',
- '⊄','⊆','⊇','⊕','⊗','⊥','⋅',
- '⌈','⌉','⌊','⌋','⟨','⟩','◊',
- '♠','♣','♥','♦'
- );
- $string = str_replace($entities, $unicode, $string);
- return $string;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement