Skip to content

Instantly share code, notes, and snippets.

@ss81
Created February 17, 2014 18:48
Show Gist options
  • Save ss81/9056554 to your computer and use it in GitHub Desktop.
Save ss81/9056554 to your computer and use it in GitHub Desktop.
Remove those Word copy and paste smart quotes
function _lym_sanitize_text($text) {
$text = mb_convert_encoding($text, 'HTML-ENTITIES', 'UTF-8');
$find[] = '“'; // left side double smart quote
$find[] = '”'; // right side double smart quote
$find[] = '‘'; // left side single smart quote
$find[] = '’'; // right side single smart quote
$find[] = '…'; // elipsis
$find[] = '—'; // em dash
$find[] = '–'; // en dash
$replace[] = '"';
$replace[] = '"';
$replace[] = "'";
$replace[] = "'";
$replace[] = "...";
$replace[] = "-";
$replace[] = "-";
return str_replace($find, $replace, $text);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment