Skip to content

Instantly share code, notes, and snippets.

@mikeselander
Created September 13, 2014 19:25
Show Gist options
  • Save mikeselander/a1d4c7b72b046d364ed1 to your computer and use it in GitHub Desktop.
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
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