Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //decode decimal HTML entities added by web browser
- $body = preg_replace('/&#\d{2,5};/ue', "utf8_entity_decode('$0')", $body );
- //decode hex HTML entities added by web browser
- $body = preg_replace('/&#x([a-fA-F0-7]{2,8});/ue', "utf8_entity_decode('&#'.hexdec('$1').';')", $body );
- //callback function for the regex
- function utf8_entity_decode($entity){
- $convmap = array(0x0, 0x10000, 0, 0xfffff);
- return mb_decode_numericentity($entity, $convmap, 'UTF-8');
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement