Re: German "Umlaute": Solution - new function for addons-library

From: Date: Wed, 05 Sep 2001 10:53:04 +0000
Subject: Re: German "Umlaute": Solution - new function for addons-library
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-1433@lists.php.net to get a copy of this message
So sprach »email.1@gmx.net« am 2001-09-05 um 10:31:37 +0200 : > I have used ereg_replace() because I have heard it is faster than > str_replace(). Yes, it is faster for "complicated" structures, but then it's slower than preg_replace. For such easy replacements, str_replace is the fastest. If you can live with the fact that this only works with PHP 4.0.5 and up, I'd even prefer: $umlaute = array('Ä', 'ä', 'Ö', 'ö', 'Ü', 'ü', 'ß'); $entities = array('&Auml;', '&auml;', '&Ouml;', '&ouml;', '&Uuml;', '&uuml;', '&szlig;'); $text = str_replace($umlaute, $entities, $text); But, I don't use this. I've made myself a "htmlent" modifier: function smarty_mod_htmlent($string, $quote_style = ENT_QUOTES) { return htmlentities($string, $quote_style); } In the template, I write {$whatever|htmlent}. If $whatever = '<äöü>', you get: '&lt;&auml;&ouml;&uuml;&gt;'. Alexander Skwar -- How to quote: http://learn.to/quote (german) http://quote.6x.to (english) Homepage: http://www.digitalprojects.com | http://www.iso-top.de iso-top.de - Die günstige Art an Linux Distributionen zu kommen Uptime: 2 days 3 hours 46 minutes

« previous php.smarty.general (#1433) next »