Created
April 26, 2011 21:22
-
-
Save pifantastic/943191 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function ec_dreammail_escape_xml($string) { | |
return htmlentities($string, ENT_QUOTES, 'UTF-8'); | |
} | |
function ec_dreammail_sanitize_xml($string) { | |
$ret = ""; | |
$length = strlen($string); | |
for ($i = 0; $i < $length; $i++) { | |
$current = ord($string[$i]); | |
if (($current == 0x9) || ($current == 0xA) || ($current == 0xD) || | |
(($current >= 0x20) && ($current <= 0xD7FF)) || | |
(($current >= 0xE000) && ($current <= 0xFFFD)) || | |
(($current >= 0x10000) && ($current <= 0x10FFFF))) { | |
$ret .= chr($current); | |
} | |
} | |
return $ret; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment