From: Chuck Hagenbuch Date: Tue, 29 Sep 2009 13:50:37 +0000 (-0400) Subject: Add a smart quotes helper to Horde_View_Helper_Text. Probably belongs in Horde_Text_F... X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=46e3448db5be2f21888f59d015c448254df9fe6e;p=horde.git Add a smart quotes helper to Horde_View_Helper_Text. Probably belongs in Horde_Text_Filter? --- diff --git a/framework/View/lib/Horde/View/Helper/Text.php b/framework/View/lib/Horde/View/Helper/Text.php index 6b308b4f9..530a5d9ed 100644 --- a/framework/View/lib/Horde/View/Helper/Text.php +++ b/framework/View/lib/Horde/View/Helper/Text.php @@ -13,7 +13,7 @@ */ /** - * View helpers for URLs + * View helpers for text * * @author Mike Naberezny * @author Derek DeVries @@ -234,4 +234,68 @@ class Horde_View_Helper_Text extends Horde_View_Helper_Base ); } + /** + * Remove smart quotes + * + * http://shiflett.org/blog/2005/oct/convert-smart-quotes-with-php + */ + public function cleanSmartQuotes($str) + { + $search = array( + '/\x96/', + '/\xE2\x80\x93/', + '/\x97/', + '/\xE2\x80\x94/', + '/\x91/', + '/\xE2\x80\x98/', + '/\x92/', + '/\xE2\x80\x99/', + '/\x93/', + '/\xE2\x80\x9C/', + '/\x94/', + '/\xE2\x80\x9D/', + '/\x85/', + '/\xE2\x80\xA6/', + '/\x95/', + '/\xE2\x80\xA2/', + '/\x09/', + + // The order of these is very important. + '/\xC2\xBC/', + '/\xBC/', + '/\xC2\xBD/', + '/\xBD/', + '/\xC2\xBE/', + '/\xBE/', + ); + + $replace = array( + '-', + '-', + '--', + '--', + "'", + "'", + "'", + "'", + '"', + '"', + '"', + '"', + '...', + '...', + '*', + '*', + ' ', + + '1/4', + '1/4', + '1/2', + '1/2', + '3/4', + '3/4', + ); + + return preg_replace($search, $replace, $str); + } }