Created
February 17, 2014 18:48
-
-
Save ss81/9056554 to your computer and use it in GitHub Desktop.
Remove those Word copy and paste smart quotes
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
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