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

From: Date: Wed, 05 Sep 2001 08:31:37 +0000
Subject: German "Umlaute": Solution - new function for addons-library
Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-1431@lists.php.net to get a copy of this message
I wrote a new function and added it to the Smarty.addons.php. The whole steps are, if you want German "Umlaute" automatically be written properly in your html-Code: 1. step function smarty_mod_make_german($string) { $string = ereg_replace ('Ä','Ä',$string); $string = ereg_replace ('ä','ä',$string); $string = ereg_replace ('Ö','Ö',$string); $string = ereg_replace ('ö','ö',$string); $string = ereg_replace ('Ü','Ü',$string); $string = ereg_replace ('ü','ü',$string); $string = ereg_replace ('ß','ß',$string); return $string; } 2.step: give the function an alias-name: add: 'german' => 'smarty_mod_make_german' to the: var $custom_mods = array(...) in: Smarty.class.php 3. step: In the template write for example { $text | german } I have used ereg_replace() because I have heard it is faster than str_replace(). The solution works. Could it be done better = faster? Thank you Hans-Peter Oeri for the hints. Maybe someone needs all this. Take care Klaus Horsten (Vienna)

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