Index: trunk/wb/search/search.php
===================================================================
--- trunk/wb/search/search.php	(revision 475)
+++ trunk/wb/search/search.php	(revision 476)
@@ -62,7 +62,7 @@
 		// and do some convertion to both
 		require(WB_PATH.'/search/search_convert.php');
 		$string = strtr($string,$string_conv_all);
-		$string_entities = strtr($string_entities,$string_entities_conv_all);
+		$string_entities = strtr($string_entities,$string_conv_all);
 		$search_string = $string_entities;
 	} else {
 		$string = '';
Index: trunk/wb/search/search_convert.php
===================================================================
--- trunk/wb/search/search_convert.php	(revision 475)
+++ trunk/wb/search/search_convert.php	(revision 476)
@@ -33,19 +33,20 @@
 	exit(0);
 }
 
+//htmlspecialchars_decode
+$string_htmlspecialchars_decode=array(
+	"&lt;"=>"<", "&gt;"=>">", "&amp;"=>"&", "&quot;"=>"\"", "&#039;"=>"\'"
+);
+//htmlspecialchars_decode
+$string_htmlspecialchars_encode=array(
+	"<"=>"&lt;", ">"=>"&gt;", "&"=>"&amp;", "\""=>"&quot;", "\'"=>"&#039;"
+);
+
 //convert some bad characters
 $string_conv_all=array(
-	"<"=>"&lt;",">"=>"&gt;","&"=>"&amp;","\""=>"&quot;","\'"=>"&#039;","!"=>" ","-"=>" ","="=>" "
-);
-$string_entities_conv_all=array(
 	"!"=>" ","-"=>" ","="=>" "
 );
 
-//htmlspecialchars_decode
-$string_htmlspecialchars_decode=array(
-	"&lt;"=>"<", "&gt;"=>">", "&amp;"=>"&", "&quot;"=>"\"", "&#039;'"=>"\'"
-);
-
 //umlauts to '(upper|lower)' for preg_match()
 //this is UTF-8-encoded
 $string_ul_umlauts = array(
@@ -55,7 +56,7 @@
 	"\xc3\xa2" => "(\xc3\xa2|\xc3\x82)",
 	"\xc3\xa3" => "(\xc3\xa3|\xc3\x83)",
 	"\xc3\xa4" => "(\xc3\xa4|\xc3\x84)",
-	"\xc3\xa5" => "(\xc3\xa5|\xc3\x85)",
+	"\xc3\xa5" => "(\xc3\xa5|\xc3\x85|\xe2\x84\xab)",
 	"\xc3\xa6" => "(\xc3\xa6|\xc3\x86)",
 	"\xc3\xa7" => "(\xc3\xa7|\xc3\x87)",
 	"\xc3\xa8" => "(\xc3\xa8|\xc3\x88)",
@@ -162,12 +163,9 @@
 	"\xc6\xb9" => "(\xc6\xb9|\xc6\xb8)",
 	"\xc6\xbd" => "(\xc6\xbd|\xc6\xbc)",
 	"\xc6\xbf" => "(\xc6\xbf|\xc7\xb7)",
-	"\xc7\x85" => "(\xc7\x85|\xc7\x84)",
-	"\xc7\x86" => "(\xc7\x86|\xc7\x84)",
-	"\xc7\x88" => "(\xc7\x88|\xc7\x87)",
-	"\xc7\x89" => "(\xc7\x89|\xc7\x87)",
-	"\xc7\x8b" => "(\xc7\x8b|\xc7\x8a)",
-	"\xc7\x8c" => "(\xc7\x8c|\xc7\x8a)",
+	"\xc7\x86" => "(\xc7\x86|\xc7\x84|\xc7\x85)",
+	"\xc7\x89" => "(\xc7\x89|\xc7\x87|\xc7\x88)",
+	"\xc7\x8c" => "(\xc7\x8c|\xc7\x8a|\xc7\x8b)",
 	"\xc7\x8e" => "(\xc7\x8e|\xc7\x8d)",
 	"\xc7\x90" => "(\xc7\x90|\xc7\x8f)",
 	"\xc7\x92" => "(\xc7\x92|\xc7\x91)",
@@ -186,8 +184,8 @@
 	"\xc7\xab" => "(\xc7\xab|\xc7\xaa)",
 	"\xc7\xad" => "(\xc7\xad|\xc7\xac)",
 	"\xc7\xaf" => "(\xc7\xaf|\xc7\xae)",
-	"\xc7\xb2" => "(\xc7\xb2|\xc7\xb1)",
-	"\xc7\xb3" => "(\xc7\xb3|\xc7\xb1)",
+	"\xc7\xb2" => "(\xc7\xb2|\xc7\xb1|\xc7\xb3)",
+	"\xc7\xb3" => "(\xc7\xb3|\xc7\xb1|\xc7\xb2)",
 	"\xc7\xb5" => "(\xc7\xb5|\xc7\xb4)",
 	"\xc7\xb9" => "(\xc7\xb9|\xc7\xb8)",
 	"\xc7\xbb" => "(\xc7\xbb|\xc7\xba)",
@@ -249,7 +247,7 @@
 	"\xce\xb5" => "(\xce\xb5|\xce\x95)",
 	"\xce\xb6" => "(\xce\xb6|\xce\x96)",
 	"\xce\xb7" => "(\xce\xb7|\xce\x97)",
-	"\xce\xb8" => "(\xce\xb8|\xce\x98)",
+	"\xce\xb8" => "(\xce\xb8|\xce\x98|\xcf\xb4)",
 	"\xce\xb9" => "(\xce\xb9|\xce\x99)",
 	"\xce\xba" => "(\xce\xba|\xce\x9a)",
 	"\xce\xbb" => "(\xce\xbb|\xce\x9b)",
@@ -266,7 +264,7 @@
 	"\xcf\x86" => "(\xcf\x86|\xce\xa6)",
 	"\xcf\x87" => "(\xcf\x87|\xce\xa7)",
 	"\xcf\x88" => "(\xcf\x88|\xce\xa8)",
-	"\xcf\x89" => "(\xcf\x89|\xce\xa9)",
+	"\xcf\x89" => "(\xcf\x89|\xce\xa9|\xe2\x84\xa6)",
 	"\xcf\x8a" => "(\xcf\x8a|\xce\xaa)",
 	"\xcf\x8b" => "(\xcf\x8b|\xce\xab)",
 	"\xcf\x8c" => "(\xcf\x8c|\xce\x8c)",
@@ -897,12 +895,12 @@
 	"\xc6\xb7" => "(\xc6\xb7|\xca\x92)",
 	"\xc6\xb8" => "(\xc6\xb8|\xc6\xb9)",
 	"\xc6\xbc" => "(\xc6\xbc|\xc6\xbd)",
-	"\xc7\x84" => "(\xc7\x84|\xc7\x86)",
-	"\xc7\x85" => "(\xc7\x85|\xc7\x86)",
-	"\xc7\x87" => "(\xc7\x87|\xc7\x89)",
-	"\xc7\x88" => "(\xc7\x88|\xc7\x89)",
-	"\xc7\x8a" => "(\xc7\x8a|\xc7\x8c)",
-	"\xc7\x8b" => "(\xc7\x8b|\xc7\x8c)",
+	"\xc7\x84" => "(\xc7\x84|\xc7\x86|\xc7\x85)",
+	"\xc7\x85" => "(\xc7\x85|\xc7\x84|\xc7\x86)",
+	"\xc7\x87" => "(\xc7\x87|\xc7\x89|\xc7\x88)",
+	"\xc7\x88" => "(\xc7\x88|\xc7\x87|\xc7\x89)",
+	"\xc7\x8a" => "(\xc7\x8a|\xc7\x8c|\xc7\x8b)",
+	"\xc7\x8b" => "(\xc7\x8b|\xc7\x8a|\xc7\x8c)",
 	"\xc7\x8d" => "(\xc7\x8d|\xc7\x8e)",
 	"\xc7\x8f" => "(\xc7\x8f|\xc7\x90)",
 	"\xc7\x91" => "(\xc7\x91|\xc7\x92)",
@@ -920,8 +918,7 @@
 	"\xc7\xaa" => "(\xc7\xaa|\xc7\xab)",
 	"\xc7\xac" => "(\xc7\xac|\xc7\xad)",
 	"\xc7\xae" => "(\xc7\xae|\xc7\xaf)",
-	"\xc7\xb1" => "(\xc7\xb1|\xc7\xb3)",
-	"\xc7\xb2" => "(\xc7\xb2|\xc7\xb3)",
+	"\xc7\xb1" => "(\xc7\xb1|\xc7\xb3|\xc7\xb2)",
 	"\xc7\xb4" => "(\xc7\xb4|\xc7\xb5)",
 	"\xc7\xb6" => "(\xc7\xb6|\xc6\x95)",
 	"\xc7\xb7" => "(\xc7\xb7|\xc6\xbf)",
@@ -962,26 +959,26 @@
 	"\xce\x8e" => "(\xce\x8e|\xcf\x8d)",
 	"\xce\x8f" => "(\xce\x8f|\xcf\x8e)",
 	"\xce\x91" => "(\xce\x91|\xce\xb1)",
-	"\xce\x92" => "(\xce\x92|\xce\xb2)",
+	"\xce\x92" => "(\xce\x92|\xce\xb2|\xcf\x90)",
 	"\xce\x93" => "(\xce\x93|\xce\xb3)",
 	"\xce\x94" => "(\xce\x94|\xce\xb4)",
-	"\xce\x95" => "(\xce\x95|\xce\xb5)",
+	"\xce\x95" => "(\xce\x95|\xce\xb5|\xcf\xb5)",
 	"\xce\x96" => "(\xce\x96|\xce\xb6)",
 	"\xce\x97" => "(\xce\x97|\xce\xb7)",
-	"\xce\x98" => "(\xce\x98|\xce\xb8)",
-	"\xce\x99" => "(\xce\x99|\xce\xb9)",
-	"\xce\x9a" => "(\xce\x9a|\xce\xba)",
+	"\xce\x98" => "(\xce\x98|\xce\xb8|\xcf\x91)",
+	"\xce\x99" => "(\xce\x99|\xce\xb9|\xcd\x85|\xe1\xbe\xbe)",
+	"\xce\x9a" => "(\xce\x9a|\xce\xba|\xcf\xb0)",
 	"\xce\x9b" => "(\xce\x9b|\xce\xbb)",
-	"\xce\x9c" => "(\xce\x9c|\xce\xbc)",
+	"\xce\x9c" => "(\xce\x9c|\xce\xbc|\xc2\xb5)",
 	"\xce\x9d" => "(\xce\x9d|\xce\xbd)",
 	"\xce\x9e" => "(\xce\x9e|\xce\xbe)",
 	"\xce\x9f" => "(\xce\x9f|\xce\xbf)",
-	"\xce\xa0" => "(\xce\xa0|\xcf\x80)",
-	"\xce\xa1" => "(\xce\xa1|\xcf\x81)",
-	"\xce\xa3" => "(\xce\xa3|\xcf\x83)",
+	"\xce\xa0" => "(\xce\xa0|\xcf\x80|\xcf\x96)",
+	"\xce\xa1" => "(\xce\xa1|\xcf\x81|\xcf\xb1)",
+	"\xce\xa3" => "(\xce\xa3|\xcf\x83|\xcf\x82|\xcf\xb2)",
 	"\xce\xa4" => "(\xce\xa4|\xcf\x84)",
 	"\xce\xa5" => "(\xce\xa5|\xcf\x85)",
-	"\xce\xa6" => "(\xce\xa6|\xcf\x86)",
+	"\xce\xa6" => "(\xce\xa6|\xcf\x86|\xcf\x95)",
 	"\xce\xa7" => "(\xce\xa7|\xcf\x87)",
 	"\xce\xa8" => "(\xce\xa8|\xcf\x88)",
 	"\xce\xa9" => "(\xce\xa9|\xcf\x89)",
@@ -1200,7 +1197,7 @@
 	"\xe1\xb9\x9a" => "(\xe1\xb9\x9a|\xe1\xb9\x9b)",
 	"\xe1\xb9\x9c" => "(\xe1\xb9\x9c|\xe1\xb9\x9d)",
 	"\xe1\xb9\x9e" => "(\xe1\xb9\x9e|\xe1\xb9\x9f)",
-	"\xe1\xb9\xa0" => "(\xe1\xb9\xa0|\xe1\xb9\xa1)",
+	"\xe1\xb9\xa0" => "(\xe1\xb9\xa0|\xe1\xb9\xa1|\xe1\xba\x9b)",
 	"\xe1\xb9\xa2" => "(\xe1\xb9\xa2|\xe1\xb9\xa3)",
 	"\xe1\xb9\xa4" => "(\xe1\xb9\xa4|\xe1\xb9\xa5)",
 	"\xe1\xb9\xa6" => "(\xe1\xb9\xa6|\xe1\xb9\xa7)",
@@ -1476,7 +1473,11 @@
 	"\xf0\x90\x90\xa2" => "(\xf0\x90\x90\xa2|\xf0\x90\x91\x8a)",
 	"\xf0\x90\x90\xa3" => "(\xf0\x90\x90\xa3|\xf0\x90\x91\x8b)",
 	"\xf0\x90\x90\xa4" => "(\xf0\x90\x90\xa4|\xf0\x90\x91\x8c)",
-	"\xf0\x90\x90\xa5" => "(\xf0\x90\x90\xa5|\xf0\x90\x91\x8d)"
+	"\xf0\x90\x90\xa5" => "(\xf0\x90\x90\xa5|\xf0\x90\x91\x8d)",
+	"i" => "(i|\xc4\xb0|I)",
+	"I" => "(I|\xc4\xb1|i)",
+	"k" => "(k|\xe2\x84\xaa|K)",
+	"S" => "(S|\xc5\xbf|s)"
 );
 
 ?>
\ No newline at end of file
Index: trunk/wb/framework/frontend.functions.php
===================================================================
--- trunk/wb/framework/frontend.functions.php	(revision 475)
+++ trunk/wb/framework/frontend.functions.php	(revision 476)
@@ -71,16 +71,14 @@
 	require_once(WB_PATH.'/framework/functions.php');
 	require(WB_PATH.'/search/search_convert.php');
 	$foo = entities_to_umlauts($foo, 'UTF-8');
-	foreach($arr_string as $string) {
-		$string = strtr($string, $string_htmlspecialchars_decode);
-		$string = entities_to_umlauts($string, 'UTF-8');
-		$string = preg_quote($string, '/');
-		$string = strtr($string, $string_ul_umlauts);
-		$foo = preg_replace('/('.$string.')(?=[^>]*<)/iUS', '<span class="highlight">$1</span>',$foo);
-		$pos = strpos($foo, '<');
-		if ($pos === false) { // "===" means identicaly
-			$foo = preg_replace('/('.$string.')/i', '<span class="highlight">$1</span>',$foo);
-		}
+	array_walk($arr_string, create_function('&$v,$k','$v = preg_quote($v, \'/\');'));
+	$search_string = implode("|", $arr_string);
+	$string = entities_to_umlauts($search_string, 'UTF-8');
+	$string = strtr($string, $string_ul_umlauts);
+	$foo = preg_replace('/('.$string.')(?=[^>]*<)/iUS', '<span class="highlight">$1</span>',$foo);
+	$pos = strpos($foo, '<');
+	if ($pos === false) { // "===" means identicaly
+		$foo = preg_replace('/('.$string.')/i', '<span class="highlight">$1</span>',$foo);
 	}
 	$foo = umlauts_to_entities($foo, 'UTF-8', 0);
 	return $foo;
Index: trunk/wb/framework/functions.php
===================================================================
--- trunk/wb/framework/functions.php	(revision 475)
+++ trunk/wb/framework/functions.php	(revision 476)
@@ -340,7 +340,9 @@
 
 // Function as replecement for php's htmlspecialchars()
 function my_htmlspecialchars($string) {
-	$string = strtr($string, array("<"=>"&lt;", ">"=>"&gt;", "\""=>"&quot;", "\'"=>"&#039;"));
+	$string = preg_replace("/&(?=[#a-z0-9]+;)/i", "_x_", $string);
+	$string = strtr($string, array("<"=>"&lt;", ">"=>"&gt;", "&"=>"&amp;", "\""=>"&quot;", "\'"=>"&#039;"));
+	$string = preg_replace("/_x_(?=[#a-z0-9]+;)/i", "&", $string);
 	return($string);
 }
 
@@ -369,11 +371,18 @@
 	if ($charset_out == $charset_in) {
 		return $string;
 	}
+	$use_iconv = true;
+	$use_mbstring = true;
+	if(version_compare(PHP_VERSION, "5.1.0", "<")) {
+		$use_mbstring = false; // don't rely on mb_convert_encoding if php<5.1.0
+		$use_iconv = false; // don't rely on iconv neither
+	}
+	
 	// try mb_convert_encoding(). This can handle to or from HTML-ENTITIES, too
-	if (function_exists('mb_convert_encoding')) {
+	if ($use_mbstring && function_exists('mb_convert_encoding')) {
 		// there's no GB2312 or ISO-8859-11 encoding in php's mb_* functions
 		if ($charset_in=='ISO-8859-11' || $charset_in=='GB2312') {
-			if (function_exists('iconv')) {
+			if ($use_iconv && function_exists('iconv')) {
 				$string = iconv($charset_in, 'UTF-8', $string);
 			}
 			else {
@@ -390,7 +399,7 @@
 		}
 		if ($charset_out=='ISO-8859-11' || $charset_out=='GB2312') {
 			$string=mb_convert_encoding($string, 'UTF-8', $charset_in);
-			if (function_exists('iconv')) {
+			if ($use_iconv && function_exists('iconv')) {
 				$string = iconv('UTF-8', $charset_out, $string);
 			}
 			else {
@@ -409,75 +418,14 @@
 	}
 
 	// try iconv(). This can't handle to or from HTML-ENTITIES.
-	if (function_exists('iconv') && $charset_out!='HTML-ENTITIES' && $charset_in!='HTML-ENTITIES' ) {
+	if ($use_iconv && function_exists('iconv') && $charset_out!='HTML-ENTITIES' && $charset_in!='HTML-ENTITIES' ) {
 		$string = iconv($charset_in, $charset_out, $string);
 		return $string;
 	}
 
-	// do the UTF-8->HTML-ENTITIES or HTML-ENTITIES->UTF-8 translation
+	// do the UTF-8->HTML-ENTITIES or HTML-ENTITIES->UTF-8 translation if mb_convert_encoding isn't available
 	if (($charset_in=='HTML-ENTITIES' && $charset_out=='UTF-8') || ($charset_in=='UTF-8' && $charset_out=='HTML-ENTITIES')) {
-		$named_to_numbered_entities=array(
-			'&nbsp;'=>'&#160;','&iexcl;'=>'&#161;','&cent;'=>'&#162;','&pound;'=>'&#163;','&curren;'=>'&#164;',
-			'&yen;'=>'&#165;','&brvbar;'=>'&#166;','&sect;'=>'&#167;','&uml;'=>'&#168;','&ordf;'=>'&#170;',
-			'&laquo;'=>'&#171;','&not;'=>'&#172;','&shy;'=>'&#173;','&reg;'=>'&#174;','&macr;'=>'&#175;',
-			'&deg;'=>'&#176;','&plusmn;'=>'&#177;','&sup2;'=>'&#178;','&sup3;'=>'&#179;','&acute;'=>'&#180;',
-			'&micro;'=>'&#181;','&para;'=>'&#182;','&middot;'=>'&#183;','&cedil;'=>'&#184;','&sup1;'=>'&#185;',
-			'&ordm;'=>'&#186;','&raquo;'=>'&#187;','&frac14;'=>'&#188;','&frac12;'=>'&#189;','&frac34;'=>'&#190;',
-			'&iquest;'=>'&#191;','&divide;'=>'&#247;','&empty;'=>'&#8709;','&euro;'=>'&#8364;',
-			'&Aacute;'=>'&#193;','&aacute;'=>'&#225;','&Acirc;'=>'&#194;',
-			'&acirc;'=>'&#226;','&AElig;'=>'&#198;','&aelig;'=>'&#230;','&Agrave;'=>'&#192;','&agrave;'=>'&#224;',
-			'&Aring;'=>'&#197;','&aring;'=>'&#229;','&Atilde;'=>'&#195;','&atilde;'=>'&#227;','&Auml;'=>'&#196;',
-			'&auml;'=>'&#228;','&Ccedil;'=>'&#199;','&ccedil;'=>'&#231;','&Eacute;'=>'&#201;','&eacute;'=>'&#233;',
-			'&Ecirc;'=>'&#202;','&ecirc;'=>'&#234;','&Egrave;'=>'&#200;','&egrave;'=>'&#232;','&Euml;'=>'&#203;',
-			'&euml;'=>'&#235;','&Iacute;'=>'&#205;','&iacute;'=>'&#237;','&Icirc;'=>'&#206;','&icirc;'=>'&#238;',
-			'&Igrave;'=>'&#204;','&igrave;'=>'&#236;','&Iuml;'=>'&#207;','&iuml;'=>'&#239;','&Ntilde;'=>'&#209;',
-			'&ntilde;'=>'&#241;','&Oacute;'=>'&#211;','&oacute;'=>'&#243;','&Ocirc;'=>'&#212;','&ocirc;'=>'&#244;',
-			'&OElig;'=>'&#338;','&oelig;'=>'&#339;','&Ograve;'=>'&#210;','&ograve;'=>'&#242;','&Otilde;'=>'&#213;',
-			'&otilde;'=>'&#245;','&Ouml;'=>'&#214;','&ouml;'=>'&#246;','&Scaron;'=>'&#352;','&scaron;'=>'&#353;',
-			'&szlig;'=>'&#223;','&Uacute;'=>'&#218;','&uacute;'=>'&#250;','&Ucirc;'=>'&#219;','&ucirc;'=>'&#251;',
-			'&Ugrave;'=>'&#217;','&ugrave;'=>'&#249;','&Uuml;'=>'&#220;','&uuml;'=>'&#252;','&Yacute;'=>'&#221;',
-			'&yacute;'=>'&#253;','&Yuml;'=>'&#376;','&yuml;'=>'&#255;','&copy;'=>'&#169;','&reg;'=>'&#174;',
-			'&ETH;'=>'&#208;','&times;'=>'&#215;','&Oslash;'=>'&#216;','&THORN;'=>'&#222;','&eth;'=>'&#240;',
-			'&oslash;'=>'&#248;','&thorn;'=>'&#254;');
-		$numbered_to_named_entities=array('&#193;'=>'&Aacute;','&#225;'=>'&aacute;','&#194;'=>'&Acirc;',
-			'&#160;'=>'&nbsp;','&#161;'=>'&iexcl;','&#162;'=>'&cent;','&#163;'=>'&pound;','&#164;'=>'&curren;',
-			'&#165;'=>'&yen;','&#166;'=>'&brvbar;','&#167;'=>'&sect;','&#168;'=>'&uml;','&#170;'=>'&ordf;',
-			'&#171;'=>'&laquo;','&#172;'=>'&not;','&#173;'=>'&shy;','&#174;'=>'&reg;','&#175;'=>'&macr;',
-			'&#176;'=>'&deg;','&#177;'=>'&plusmn;','&#178;'=>'&sup2;','&#179;'=>'&sup3;','&#180;'=>'&acute;',
-			'&#181;'=>'&micro;','&#182;'=>'&para;','&#183;'=>'&middot;','&#184;'=>'&cedil;','&#185;'=>'&sup1;',
-			'&#186;'=>'&ordm;','&#187;'=>'&raquo;','&#188;'=>'&frac14;','&#189;'=>'&frac12;','&#190;'=>'&frac34;',
-			'&#191;'=>'&iquest;','&#247;'=>'&divide;','&#8709;'=>'&empty;','&#8364;'=>'&euro;',
-			'&#226;'=>'&acirc;','&#198;'=>'&AElig;','&#230;'=>'&aelig;','&#192;'=>'&Agrave;','&#224;'=>'&agrave;',
-			'&#197;'=>'&Aring;','&#229;'=>'&aring;','&#195;'=>'&Atilde;','&#227;'=>'&atilde;','&#196;'=>'&Auml;',
-			'&#228;'=>'&auml;','&#199;'=>'&Ccedil;','&#231;'=>'&ccedil;','&#201;'=>'&Eacute;','&#233;'=>'&eacute;',
-			'&#202;'=>'&Ecirc;','&#234;'=>'&ecirc;','&#200;'=>'&Egrave;','&#232;'=>'&egrave;','&#203;'=>'&Euml;',
-			'&#235;'=>'&euml;','&#205;'=>'&Iacute;','&#237;'=>'&iacute;','&#206;'=>'&Icirc;','&#238;'=>'&icirc;',
-			'&#204;'=>'&Igrave;','&#236;'=>'&igrave;','&#207;'=>'&Iuml;','&#239;'=>'&iuml;','&#209;'=>'&Ntilde;',
-			'&#241;'=>'&ntilde;','&#211;'=>'&Oacute;','&#243;'=>'&oacute;','&#212;'=>'&Ocirc;','&#244;'=>'&ocirc;',
-			'&#338;'=>'&OElig;','&#339;'=>'&oelig;','&#210;'=>'&Ograve;','&#242;'=>'&ograve;','&#213;'=>'&Otilde;',
-			'&#245;'=>'&otilde;','&#214;'=>'&Ouml;','&#246;'=>'&ouml;','&#352;'=>'&Scaron;','&#353;'=>'&scaron;',
-			'&#223;'=>'&szlig;','&#218;'=>'&Uacute;','&#250;'=>'&uacute;','&#219;'=>'&Ucirc;','&#251;'=>'&ucirc;',
-			'&#217;'=>'&Ugrave;','&#249;'=>'&ugrave;','&#220;'=>'&Uuml;','&#252;'=>'&uuml;','&#221;'=>'&Yacute;',
-			'&#253;'=>'&yacute;','&#376;'=>'&Yuml;','&#255;'=>'&yuml;','&#169;'=>'&copy;','&#174;'=>'&reg;',
-			'&#208;'=>'&ETH;','&#215;'=>'&times;','&#216;'=>'&Oslash;','&#222;'=>'&THORN;','&#240;'=>'&eth;',
-			'&#248;'=>'&oslash;','&#254;'=>'&thorn;');
-		if ($charset_in == 'HTML-ENTITIES') {
-			$string = strtr($string, $named_to_numbered_entities);
-			$string = preg_replace("/&#([0-9]+);/e", "code_to_utf8($1)", $string);
-		}
-		elseif ($charset_out == 'HTML-ENTITIES') {
-			$string = preg_replace("/&#([0-9]+);/e", "code_to_utf8($1)", $string);
-			$char = "";
-			while (strlen($string) > 0) {
-				preg_match("/^(.)(.*)$/su", $string, $match);
-				if (strlen($match[1]) > 1) {
-					$char .= "&#".uniord($match[1]).";";
-				} else $char .= $match[1];
-				$string = $match[2];
-			}
-			$string = $char;
-			$string = strtr($string, $numbered_to_named_entities);
-		}
+		$string = string_decode_encode_entities($string, $charset_out, $charset_in);
 		return $string;
 	}
 
@@ -530,7 +478,140 @@
 	// and mbstring _and_ iconv aren't available.
 	return $string;
 }
-// support-function for mb_convert_encoding_wrapper()
+
+// Decodes or encodes html-entities. Works for utf-8 only!
+function string_decode_encode_entities($string, $out='HTML-ENTITIES', $in='UTF-8') {
+	if(!(($in=='UTF-8' || $in=='HTML-ENTITIES') && ($out=='UTF-8' || $out=='HTML-ENTITIES'))) {
+		return $string;
+	}
+	$named_to_numbered_entities=array(
+		'&Aacute;'=>'&#193;','&aacute;'=>'&#225;',
+		'&Acirc;'=>'&#194;','&acirc;'=>'&#226;','&acute;'=>'&#180;','&AElig;'=>'&#198;','&aelig;'=>'&#230;',
+		'&Agrave;'=>'&#192;','&agrave;'=>'&#224;','&alefsym;'=>'&#8501;','&Alpha;'=>'&#913;','&alpha;'=>'&#945;',
+		'&amp;'=>'&#38;','&and;'=>'&#8743;','&ang;'=>'&#8736;','&apos;'=>'&#39;','&Aring;'=>'&#197;','&aring;'=>'&#229;',
+		'&asymp;'=>'&#8776;','&Atilde;'=>'&#195;','&atilde;'=>'&#227;','&Auml;'=>'&#196;','&auml;'=>'&#228;',
+		'&bdquo;'=>'&#8222;','&Beta;'=>'&#914;','&beta;'=>'&#946;','&brvbar;'=>'&#166;','&bull;'=>'&#8226;',
+		'&cap;'=>'&#8745;','&Ccedil;'=>'&#199;','&ccedil;'=>'&#231;','&cedil;'=>'&#184;','&cent;'=>'&#162;',
+		'&Chi;'=>'&#935;','&chi;'=>'&#967;','&circ;'=>'&#710;','&clubs;'=>'&#9827;','&cong;'=>'&#8773;',
+		'&copy;'=>'&#169;','&crarr;'=>'&#8629;','&cup;'=>'&#8746;','&curren;'=>'&#164;','&Dagger;'=>'&#8225;',
+		'&dagger;'=>'&#8224;','&dArr;'=>'&#8659;','&darr;'=>'&#8595;','&deg;'=>'&#176;','&Delta;'=>'&#916;',
+		'&delta;'=>'&#948;','&diams;'=>'&v#9830;','&divide;'=>'&#247;','&Eacute;'=>'&#201;','&eacute;'=>'&#233;',
+		'&Ecirc;'=>'&#202;','&ecirc;'=>'&#234;','&Egrave;'=>'&#200;','&egrave;'=>'&#232;','&empty;'=>'&#8709;',
+		'&emsp;'=>'&#8195;','&ensp;'=>'&#8194;','&Epsilon;'=>'&#917;','&epsilon;'=>'&#949;','&equiv;'=>'&#8801;',
+		'&Eta;'=>'&#919;','&eta;'=>'&#951;','&ETH;'=>'&#208;','&eth;'=>'&#240;','&Euml;'=>'&#203;','&euml;'=>'&#235;',
+		'&euro;'=>'&#8364;','&exist;'=>'&#8707;','&fnof;'=>'&#402;','&forall;'=>'&#8704;','&frac12;'=>'&#189;',
+		'&frac14;'=>'&#188;','&frac34;'=>'&#190;','&frasl;'=>'&#8260;','&Gamma;'=>'&#915;','&gamma;'=>'&#947;',
+		'&ge;'=>'&#8805;','&gt;'=>'&#62;','&hArr;'=>'&#8660;','&harr;'=>'&#8596;','&hearts;'=>'&#9829;',
+		'&hellip;'=>'&#8230;','&Iacute;'=>'&#205;','&iacute;'=>'&#237;','&Icirc;'=>'&#206;','&icirc;'=>'&#238;',
+		'&iexcl;'=>'&#161;','&Igrave;'=>'&#204;','&igrave;'=>'&#236;','&image;'=>'&#8465;','&infin;'=>'&#8734;',
+		'&int;'=>'&#8747;','&Iota;'=>'&#921;','&iota;'=>'&#953;','&iquest;'=>'&#191;','&isin;'=>'&#8712;',
+		'&Iuml;'=>'&#207;','&iuml;'=>'&#239;','&Kappa;'=>'&#922;','&kappa;'=>'&#954;','&Lambda;'=>'&#923;',
+		'&lambda;'=>'&#955;','&lang;'=>'&#9001;','&laquo;'=>'&#171;','&lArr;'=>'&#8656;','&larr;'=>'&#8592;',
+		'&lceil;'=>'&#8968;','&ldquo;'=>'&#8220;','&le;'=>'&#8804;','&lfloor;'=>'&#8970;','&lowast;'=>'&#8727;',
+		'&loz;'=>'&#9674;','&lrm;'=>'&#8206;','&lsaquo;'=>'&#8249;','&lsquo;'=>'&#8216;','&lt;'=>'&#60;',
+		'&macr;'=>'&#175;','&mdash;'=>'&#8212;','&micro;'=>'&#181;','&middot;'=>'&#183;','&minus;'=>'&#8722;',
+		'&Mu;'=>'&#924;','&mu;'=>'&#956;','&nabla;'=>'&#8711;','&nbsp;'=>'&#160;','&ndash;'=>'&#8211;',
+		'&ne;'=>'&#8800;','&ni;'=>'&#8715;','&not;'=>'&#172;','&notin;'=>'&#8713;','&nsub;'=>'&#8836;',
+		'&Ntilde;'=>'&#209;','&ntilde;'=>'&#241;','&Nu;'=>'&#925;','&nu;'=>'&#957;','&Oacute;'=>'&#211;',
+		'&oacute;'=>'&#243;','&Ocirc;'=>'&#212;','&ocirc;'=>'&#244;','&OElig;'=>'&#338;','&oelig;'=>'&#339;',
+		'&Ograve;'=>'&#210;','&ograve;'=>'&#242;','&oline;'=>'&#8254;','&Omega;'=>'&#937;','&omega;'=>'&#969;',
+		'&Omicron;'=>'&#927;','&omicron;'=>'&#959;','&oplus;'=>'&#8853;','&or;'=>'&#8744;','&ordf;'=>'&#170;',
+		'&ordm;'=>'&#186;','&Oslash;'=>'&#216;','&oslash;'=>'&#248;','&Otilde;'=>'&#213;','&otilde;'=>'&#245;',
+		'&otimes;'=>'&#8855;','&Ouml;'=>'&#214;','&ouml;'=>'&#246;','&para;'=>'&#182;','&part;'=>'&#8706;',
+		'&permil;'=>'&#8240;','&perp;'=>'&#8869;','&Phi;'=>'&#934;','&phi;'=>'&#966;','&Pi;'=>'&#928;',
+		'&pi;'=>'&#960;','&piv;'=>'&#982;','&plusmn;'=>'&#177;','&pound;'=>'&#163;','&Prime;'=>'&#8243;',
+		'&prime;'=>'&#8242;','&prod;'=>'&#8719;','&prop;'=>'&#8733;','&Psi;'=>'&#936;','&psi;'=>'&#968;',
+		'&quot;'=>'&#34;','&radic;'=>'&#8730;','&rang;'=>'&#9002;','&raquo;'=>'&#187;','&rArr;'=>'&#8658;',
+		'&rarr;'=>'&#8594;','&rceil;'=>'&#8969;','&rdquo;'=>'&#8221;','&real;'=>'&#8476;','&reg;'=>'&#174;',
+		'&rfloor;'=>'&#8971;','&Rho;'=>'&#929;','&rho;'=>'&#961;','&rlm;'=>'&#8207;','&rsaquo;'=>'&#8250;',
+		'&rsquo;'=>'&#8217;','&sbquo;'=>'&#8218;','&Scaron;'=>'&#352;','&scaron;'=>'&#353;','&sdot;'=>'&#8901;',
+		'&sect;'=>'&#167;','&shy;'=>'&#173;','&Sigma;'=>'&#931;','&sigma;'=>'&#963;','&sigmaf;'=>'&#962;',
+		'&sim;'=>'&#8764;','&spades;'=>'&#9824;','&sub;'=>'&#8834;','&sube;'=>'&#8838;','&sum;'=>'&#8721;',
+		'&sup;'=>'&#8835;','&sup1;'=>'&#185;','&sup2;'=>'&#178;','&sup3;'=>'&#179;','&supe;'=>'&#8839;',
+		'&szlig;'=>'&#223;','&Tau;'=>'&#932;','&tau;'=>'&#964;','&there4;'=>'&#8756;','&Theta;'=>'&#920;',
+		'&theta;'=>'&#952;','&thetasym;'=>'&#977;','&thinsp;'=>'&#8201;','&THORN;'=>'&#222;','&thorn;'=>'&#254;',
+		'&tilde;'=>'&#732;','&times;'=>'&#215;','&trade;'=>'&#8482;','&Uacute;'=>'&#218;','&uacute;'=>'&#250;',
+		'&uArr;'=>'&#8657;','&uarr;'=>'&#8593;','&Ucirc;'=>'&#219;','&ucirc;'=>'&#251;','&Ugrave;'=>'&#217;',
+		'&ugrave;'=>'&#249;','&uml;'=>'&#168;','&upsih;'=>'&#978;','&Upsilon;'=>'&#933;','&upsilon;'=>'&#965;',
+		'&Uuml;'=>'&#220;','&uuml;'=>'&#252;','&weierp;'=>'&#8472;','&Xi;'=>'&#926;','&xi;'=>'&#958;',
+		'&Yacute;'=>'&#221;','&yacute;'=>'&#253;','&yen;'=>'&#165;','&Yuml;'=>'&#376;','&yuml;'=>'&#255;',
+		'&Zeta;'=>'&#918;','&zeta;'=>'&#950;','&zwj;'=>'&#8205;','&zwnj;'=>'&#8204;'
+	);
+	$numbered_to_named_entities=array(
+		'&#193;'=>'&Aacute;','&#225;'=>'&aacute;','&#194;'=>'&Acirc;','&#226;'=>'&acirc;','&#180;'=>'&acute;',
+		'&#198;'=>'&AElig;','&#230;'=>'&aelig;','&#192;'=>'&Agrave;','&#224;'=>'&agrave;','&#8501;'=>'&alefsym;',
+		'&#913;'=>'&Alpha;','&#945;'=>'&alpha;','&#38;'=>'&amp;','&#8743;'=>'&and;','&#8736;'=>'&ang;',
+		'&#39;'=>'&apos;','&#197;'=>'&Aring;','&#229;'=>'&aring;','&#8776;'=>'&asymp;','&#195;'=>'&Atilde;',
+		'&#227;'=>'&atilde;','&#196;'=>'&Auml;','&#228;'=>'&auml;','&#8222;'=>'&bdquo;','&#914;'=>'&Beta;',
+		'&#946;'=>'&beta;','&#166;'=>'&brvbar;','&#8226;'=>'&bull;','&#8745;'=>'&cap;','&#199;'=>'&Ccedil;',
+		'&#231;'=>'&ccedil;','&#184;'=>'&cedil;','&#162;'=>'&cent;','&#935;'=>'&Chi;','&#967;'=>'&chi;',
+		'&#710;'=>'&circ;','&#9827;'=>'&clubs;','&#8773;'=>'&cong;','&#169;'=>'&copy;','&#8629;'=>'&crarr;',
+		'&#8746;'=>'&cup;','&#164;'=>'&curren;','&#8225;'=>'&Dagger;','&#8224;'=>'&dagger;','&#8659;'=>'&dArr;',
+		'&#8595;'=>'&darr;','&#176;'=>'&deg;','&#916;'=>'&Delta;','&#948;'=>'&delta;','&v#9830;'=>'&diams;',
+		'&#247;'=>'&divide;','&#201;'=>'&Eacute;','&#233;'=>'&eacute;','&#202;'=>'&Ecirc;','&#234;'=>'&ecirc;',
+		'&#200;'=>'&Egrave;','&#232;'=>'&egrave;','&#8709;'=>'&empty;','&#8195;'=>'&emsp;','&#8194;'=>'&ensp;',
+		'&#917;'=>'&Epsilon;','&#949;'=>'&epsilon;','&#8801;'=>'&equiv;','&#919;'=>'&Eta;','&#951;'=>'&eta;',
+		'&#208;'=>'&ETH;','&#240;'=>'&eth;','&#203;'=>'&Euml;','&#235;'=>'&euml;','&#8364;'=>'&euro;',
+		'&#8707;'=>'&exist;','&#402;'=>'&fnof;','&#8704;'=>'&forall;','&#189;'=>'&frac12;','&#188;'=>'&frac14;',
+		'&#190;'=>'&frac34;','&#8260;'=>'&frasl;','&#915;'=>'&Gamma;','&#947;'=>'&gamma;','&#8805;'=>'&ge;',
+		'&#62;'=>'&gt;','&#8660;'=>'&hArr;','&#8596;'=>'&harr;','&#9829;'=>'&hearts;','&#8230;'=>'&hellip;',
+		'&#205;'=>'&Iacute;','&#237;'=>'&iacute;','&#206;'=>'&Icirc;','&#238;'=>'&icirc;','&#161;'=>'&iexcl;',
+		'&#204;'=>'&Igrave;','&#236;'=>'&igrave;','&#8465;'=>'&image;','&#8734;'=>'&infin;','&#8747;'=>'&int;',
+		'&#921;'=>'&Iota;','&#953;'=>'&iota;','&#191;'=>'&iquest;','&#8712;'=>'&isin;','&#207;'=>'&Iuml;',
+		'&#239;'=>'&iuml;','&#922;'=>'&Kappa;','&#954;'=>'&kappa;','&#923;'=>'&Lambda;','&#955;'=>'&lambda;',
+		'&#9001;'=>'&lang;','&#171;'=>'&laquo;','&#8656;'=>'&lArr;','&#8592;'=>'&larr;','&#8968;'=>'&lceil;',
+		'&#8220;'=>'&ldquo;','&#8804;'=>'&le;','&#8970;'=>'&lfloor;','&#8727;'=>'&lowast;','&#9674;'=>'&loz;',
+		'&#8206;'=>'&lrm;','&#8249;'=>'&lsaquo;','&#8216;'=>'&lsquo;','&#60;'=>'&lt;','&#175;'=>'&macr;',
+		'&#8212;'=>'&mdash;','&#181;'=>'&micro;','&#183;'=>'&middot;','&#8722;'=>'&minus;','&#924;'=>'&Mu;',
+		'&#956;'=>'&mu;','&#8711;'=>'&nabla;','&#160;'=>'&nbsp;','&#8211;'=>'&ndash;','&#8800;'=>'&ne;',
+		'&#8715;'=>'&ni;','&#172;'=>'&not;','&#8713;'=>'&notin;','&#8836;'=>'&nsub;','&#209;'=>'&Ntilde;',
+		'&#241;'=>'&ntilde;','&#925;'=>'&Nu;','&#957;'=>'&nu;','&#211;'=>'&Oacute;','&#243;'=>'&oacute;',
+		'&#212;'=>'&Ocirc;','&#244;'=>'&ocirc;','&#338;'=>'&OElig;','&#339;'=>'&oelig;','&#210;'=>'&Ograve;',
+		'&#242;'=>'&ograve;','&#8254;'=>'&oline;','&#937;'=>'&Omega;','&#969;'=>'&omega;','&#927;'=>'&Omicron;',
+		'&#959;'=>'&omicron;','&#8853;'=>'&oplus;','&#8744;'=>'&or;','&#170;'=>'&ordf;','&#186;'=>'&ordm;',
+		'&#216;'=>'&Oslash;','&#248;'=>'&oslash;','&#213;'=>'&Otilde;','&#245;'=>'&otilde;','&#8855;'=>'&otimes;',
+		'&#214;'=>'&Ouml;','&#246;'=>'&ouml;','&#182;'=>'&para;','&#8706;'=>'&part;','&#8240;'=>'&permil;',
+		'&#8869;'=>'&perp;','&#934;'=>'&Phi;','&#966;'=>'&phi;','&#928;'=>'&Pi;','&#960;'=>'&pi;','&#982;'=>'&piv;',
+		'&#177;'=>'&plusmn;','&#163;'=>'&pound;','&#8243;'=>'&Prime;','&#8242;'=>'&prime;','&#8719;'=>'&prod;',
+		'&#8733;'=>'&prop;','&#936;'=>'&Psi;','&#968;'=>'&psi;','&#34;'=>'&quot;','&#8730;'=>'&radic;',
+		'&#9002;'=>'&rang;','&#187;'=>'&raquo;','&#8658;'=>'&rArr;','&#8594;'=>'&rarr;','&#8969;'=>'&rceil;',
+		'&#8221;'=>'&rdquo;','&#8476;'=>'&real;','&#174;'=>'&reg;','&#8971;'=>'&rfloor;','&#929;'=>'&Rho;',
+		'&#961;'=>'&rho;','&#8207;'=>'&rlm;','&#8250;'=>'&rsaquo;','&#8217;'=>'&rsquo;','&#8218;'=>'&sbquo;',
+		'&#352;'=>'&Scaron;','&#353;'=>'&scaron;','&#8901;'=>'&sdot;','&#167;'=>'&sect;','&#173;'=>'&shy;',
+		'&#931;'=>'&Sigma;','&#963;'=>'&sigma;','&#962;'=>'&sigmaf;','&#8764;'=>'&sim;','&#9824;'=>'&spades;',
+		'&#8834;'=>'&sub;','&#8838;'=>'&sube;','&#8721;'=>'&sum;','&#8835;'=>'&sup;','&#185;'=>'&sup1;',
+		'&#178;'=>'&sup2;','&#179;'=>'&sup3;','&#8839;'=>'&supe;','&#223;'=>'&szlig;','&#932;'=>'&Tau;',
+		'&#964;'=>'&tau;','&#8756;'=>'&there4;','&#920;'=>'&Theta;','&#952;'=>'&theta;','&#977;'=>'&thetasym;',
+		'&#8201;'=>'&thinsp;','&#222;'=>'&THORN;','&#254;'=>'&thorn;','&#732;'=>'&tilde;','&#215;'=>'&times;',
+		'&#8482;'=>'&trade;','&#218;'=>'&Uacute;','&#250;'=>'&uacute;','&#8657;'=>'&uArr;','&#8593;'=>'&uarr;',
+		'&#219;'=>'&Ucirc;','&#251;'=>'&ucirc;','&#217;'=>'&Ugrave;','&#249;'=>'&ugrave;','&#168;'=>'&uml;',
+		'&#978;'=>'&upsih;','&#933;'=>'&Upsilon;','&#965;'=>'&upsilon;','&#220;'=>'&Uuml;','&#252;'=>'&uuml;',
+		'&#8472;'=>'&weierp;','&#926;'=>'&Xi;','&#958;'=>'&xi;','&#221;'=>'&Yacute;','&#253;'=>'&yacute;',
+		'&#165;'=>'&yen;','&#376;'=>'&Yuml;','&#255;'=>'&yuml;','&#918;'=>'&Zeta;','&#950;'=>'&zeta;','&#8205;'=>'&zwj;',
+		'&#8204;'=>'&zwnj;'
+	);
+		
+	if ($in == 'HTML-ENTITIES') {
+		$string = strtr($string, $named_to_numbered_entities);
+		$string = preg_replace("/&#([0-9]+);/e", "code_to_utf8($1)", $string);
+	}
+	elseif ($out == 'HTML-ENTITIES') {
+		//$string = preg_replace("/&#([0-9]+);/e", "code_to_utf8($1)", $string);
+		$char = "";
+		while (strlen($string) > 0) {
+			preg_match("/^(.)(.*)$/su", $string, $match);
+			if (strlen($match[1]) > 1) {
+				$char .= "&#".uniord($match[1]).";";
+			} else $char .= $match[1];
+			$string = $match[2];
+		}
+		$string = $char;
+		$string = strtr($string, $numbered_to_named_entities);
+	}
+	return $string;
+}
+
+// support-function for string_decode_encode_entities()
 function uniord($c) {
         $ud = 0;
         if (ord($c{0}) >= 0 && ord($c{0}) <= 127) $ud = ord($c{0});
@@ -604,22 +685,54 @@
 function entities_to_umlauts($string, $charset_out=DEFAULT_CHARSET, $convert_htmlspecialchars=0) {
 	$charset_out = strtoupper($charset_out);
 	if ($charset_out == '') { $charset_out = 'ISO-8859-1'; }
-	$string = string_to_utf8($string);
-	if($charset_out!='UTF-8' && is_UTF8($string)) {
+	$charset_in = strtoupper(DEFAULT_CHARSET);
+	
+	// string to utf-8
+	if ($charset_in == 'ISO-8859-1' || $charset_in == 'UTF-8') {
+		if ($charset_in == 'ISO-8859-1') {
+			$string=utf8_encode($string);
+		}
+		// decode html-entities
+		if(preg_match("/&[#a-zA-Z0-9]+;/", $string)) {
+			$string=string_decode_encode_entities($string, 'UTF-8', 'HTML-ENTITIES');
+		}
+	}
+	else {
+		$string = string_to_utf8($string); // will decode html-entities, too.
+	}
+	// string to $charset_out
+	if($charset_out == 'ISO-8859-1') {
+			$string=utf8_decode($string);
+	}
+	elseif($charset_out != 'UTF-8' && is_UTF8($string)) {
 		$string=mb_convert_encoding_wrapper($string, $charset_out, 'UTF-8');
 	}
-	return($string);
-}
+	return $string;
+}	
 
 // Function to convert a string from mixed html-entitites/$charset_in-umlauts to pure html-entities
 function umlauts_to_entities($string, $charset_in=DEFAULT_CHARSET, $convert_htmlspecialchars=0) {
 	$charset_in = strtoupper($charset_in);
 	if ($charset_in == "") { $charset_in = 'ISO-8859-1'; }
-	$string = string_to_utf8($string, $charset_in);
-	if (is_UTF8($string)) {
-		$string=mb_convert_encoding_wrapper($string,'HTML-ENTITIES','UTF-8');
+
+	// string to utf-8
+	if ($charset_in == 'ISO-8859-1' || $charset_in == 'UTF-8') {
+		if ($charset_in == 'ISO-8859-1') {
+			$string=utf8_encode($string);
+		}
+		// encode html-entities
+		$string=string_decode_encode_entities($string, 'HTML-ENTITIES', 'UTF-8');
+		//$string=mb_convert_encoding_wrapper($string, 'HTML-ENTITIES', 'UTF-8');
 	}
-	return($string);
+	else {
+		$string = string_to_utf8($string, $charset_in);
+		// encode html-entities
+		if (is_UTF8($string)) {
+			$string=string_decode_encode_entities($string, 'HTML-ENTITIES', 'UTF-8');
+			//$string=mb_convert_encoding_wrapper($string, 'HTML-ENTITIES', 'UTF-8');
+		}
+	}
+	return $string;
 }
 
 // translate any latin/greek/cyrillic html-entities to their plain 7bit equivalents
