Last active
August 29, 2015 14:19
-
-
Save aa21/29ce1c33459de834aa4e 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
//source: http://www.toao.net/48-replacing-smart-quotes-and-em-dashes-in-mysql | |
//By Mango, March 5th, 2009 | |
//clean charset | |
function c($text){ | |
// First, replace UTF-8 characters. | |
$text = str_replace( | |
array("\xe2\x80\x98", "\xe2\x80\x99", "\xe2\x80\x9c", "\xe2\x80\x9d", "\xe2\x80\x93", "\xe2\x80\x94", "\xe2\x80\xa6"), | |
array("'", "'", '"', '"', '-', '--', '...'), | |
$text | |
); | |
// Next, replace their Windows-1252 equivalents. | |
$text = str_replace( | |
array(chr(145), chr(146), chr(147), chr(148), chr(150), chr(151), chr(133)), | |
array("'", "'", '"', '"', '-', '--', '...'), | |
$text | |
); | |
return $text; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment