Created
September 13, 2014 19:25
-
-
Save mikeselander/a1d4c7b72b046d364ed1 to your computer and use it in GitHub Desktop.
Sanitize Text (from Word in the first one)
Word stuff from: http://www.paulund.co.uk/sanitize-special-word-characters
This file contains hidden or 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
function sanitize_from_word( $content ) | |
{ | |
// Convert microsoft special characters | |
$replace = array( | |
"‘" => "'", | |
"’" => "'", | |
"”" => '"', | |
"“" => '"', | |
"–" => "-", | |
"—" => "-", | |
"…" => "…" | |
); | |
foreach($replace as $k => $v) | |
{ | |
$content = str_replace($k, $v, $content); | |
} | |
// Remove any non-ascii character | |
$content = preg_replace('/[^\x20-\x7E]*/','', $content); | |
return $content; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment