Project

General

Profile

« Previous | Next » 

Revision 477

Added by Matthias over 17 years ago

Added changeset [476] also to branches

View differences:

branches/2.6.x/wb/search/search.php
62 62
		// and do some convertion to both
63 63
		require(WB_PATH.'/search/search_convert.php');
64 64
		$string = strtr($string,$string_conv_all);
65
		$string_entities = strtr($string_entities,$string_entities_conv_all);
65
		$string_entities = strtr($string_entities,$string_conv_all);
66 66
		$search_string = $string_entities;
67 67
	} else {
68 68
		$string = '';
branches/2.6.x/wb/search/search_convert.php
33 33
	exit(0);
34 34
}
35 35

  
36
//htmlspecialchars_decode
37
$string_htmlspecialchars_decode=array(
38
	"&lt;"=>"<", "&gt;"=>">", "&amp;"=>"&", "&quot;"=>"\"", "&#039;"=>"\'"
39
);
40
//htmlspecialchars_decode
41
$string_htmlspecialchars_encode=array(
42
	"<"=>"&lt;", ">"=>"&gt;", "&"=>"&amp;", "\""=>"&quot;", "\'"=>"&#039;"
43
);
44

  
36 45
//convert some bad characters
37 46
$string_conv_all=array(
38
	"<"=>"&lt;",">"=>"&gt;","&"=>"&amp;","\""=>"&quot;","\'"=>"&#039;","!"=>" ","-"=>" ","="=>" "
39
);
40
$string_entities_conv_all=array(
41 47
	"!"=>" ","-"=>" ","="=>" "
42 48
);
43 49

  
44
//htmlspecialchars_decode
45
$string_htmlspecialchars_decode=array(
46
	"&lt;"=>"<", "&gt;"=>">", "&amp;"=>"&", "&quot;"=>"\"", "&#039;'"=>"\'"
47
);
48

  
49 50
//umlauts to '(upper|lower)' for preg_match()
50 51
//this is UTF-8-encoded
51 52
$string_ul_umlauts = array(
......
55 56
	"\xc3\xa2" => "(\xc3\xa2|\xc3\x82)",
56 57
	"\xc3\xa3" => "(\xc3\xa3|\xc3\x83)",
57 58
	"\xc3\xa4" => "(\xc3\xa4|\xc3\x84)",
58
	"\xc3\xa5" => "(\xc3\xa5|\xc3\x85)",
59
	"\xc3\xa5" => "(\xc3\xa5|\xc3\x85|\xe2\x84\xab)",
59 60
	"\xc3\xa6" => "(\xc3\xa6|\xc3\x86)",
60 61
	"\xc3\xa7" => "(\xc3\xa7|\xc3\x87)",
61 62
	"\xc3\xa8" => "(\xc3\xa8|\xc3\x88)",
......
162 163
	"\xc6\xb9" => "(\xc6\xb9|\xc6\xb8)",
163 164
	"\xc6\xbd" => "(\xc6\xbd|\xc6\xbc)",
164 165
	"\xc6\xbf" => "(\xc6\xbf|\xc7\xb7)",
165
	"\xc7\x85" => "(\xc7\x85|\xc7\x84)",
166
	"\xc7\x86" => "(\xc7\x86|\xc7\x84)",
167
	"\xc7\x88" => "(\xc7\x88|\xc7\x87)",
168
	"\xc7\x89" => "(\xc7\x89|\xc7\x87)",
169
	"\xc7\x8b" => "(\xc7\x8b|\xc7\x8a)",
170
	"\xc7\x8c" => "(\xc7\x8c|\xc7\x8a)",
166
	"\xc7\x86" => "(\xc7\x86|\xc7\x84|\xc7\x85)",
167
	"\xc7\x89" => "(\xc7\x89|\xc7\x87|\xc7\x88)",
168
	"\xc7\x8c" => "(\xc7\x8c|\xc7\x8a|\xc7\x8b)",
171 169
	"\xc7\x8e" => "(\xc7\x8e|\xc7\x8d)",
172 170
	"\xc7\x90" => "(\xc7\x90|\xc7\x8f)",
173 171
	"\xc7\x92" => "(\xc7\x92|\xc7\x91)",
......
186 184
	"\xc7\xab" => "(\xc7\xab|\xc7\xaa)",
187 185
	"\xc7\xad" => "(\xc7\xad|\xc7\xac)",
188 186
	"\xc7\xaf" => "(\xc7\xaf|\xc7\xae)",
189
	"\xc7\xb2" => "(\xc7\xb2|\xc7\xb1)",
190
	"\xc7\xb3" => "(\xc7\xb3|\xc7\xb1)",
187
	"\xc7\xb2" => "(\xc7\xb2|\xc7\xb1|\xc7\xb3)",
188
	"\xc7\xb3" => "(\xc7\xb3|\xc7\xb1|\xc7\xb2)",
191 189
	"\xc7\xb5" => "(\xc7\xb5|\xc7\xb4)",
192 190
	"\xc7\xb9" => "(\xc7\xb9|\xc7\xb8)",
193 191
	"\xc7\xbb" => "(\xc7\xbb|\xc7\xba)",
......
249 247
	"\xce\xb5" => "(\xce\xb5|\xce\x95)",
250 248
	"\xce\xb6" => "(\xce\xb6|\xce\x96)",
251 249
	"\xce\xb7" => "(\xce\xb7|\xce\x97)",
252
	"\xce\xb8" => "(\xce\xb8|\xce\x98)",
250
	"\xce\xb8" => "(\xce\xb8|\xce\x98|\xcf\xb4)",
253 251
	"\xce\xb9" => "(\xce\xb9|\xce\x99)",
254 252
	"\xce\xba" => "(\xce\xba|\xce\x9a)",
255 253
	"\xce\xbb" => "(\xce\xbb|\xce\x9b)",
......
266 264
	"\xcf\x86" => "(\xcf\x86|\xce\xa6)",
267 265
	"\xcf\x87" => "(\xcf\x87|\xce\xa7)",
268 266
	"\xcf\x88" => "(\xcf\x88|\xce\xa8)",
269
	"\xcf\x89" => "(\xcf\x89|\xce\xa9)",
267
	"\xcf\x89" => "(\xcf\x89|\xce\xa9|\xe2\x84\xa6)",
270 268
	"\xcf\x8a" => "(\xcf\x8a|\xce\xaa)",
271 269
	"\xcf\x8b" => "(\xcf\x8b|\xce\xab)",
272 270
	"\xcf\x8c" => "(\xcf\x8c|\xce\x8c)",
......
897 895
	"\xc6\xb7" => "(\xc6\xb7|\xca\x92)",
898 896
	"\xc6\xb8" => "(\xc6\xb8|\xc6\xb9)",
899 897
	"\xc6\xbc" => "(\xc6\xbc|\xc6\xbd)",
900
	"\xc7\x84" => "(\xc7\x84|\xc7\x86)",
901
	"\xc7\x85" => "(\xc7\x85|\xc7\x86)",
902
	"\xc7\x87" => "(\xc7\x87|\xc7\x89)",
903
	"\xc7\x88" => "(\xc7\x88|\xc7\x89)",
904
	"\xc7\x8a" => "(\xc7\x8a|\xc7\x8c)",
905
	"\xc7\x8b" => "(\xc7\x8b|\xc7\x8c)",
898
	"\xc7\x84" => "(\xc7\x84|\xc7\x86|\xc7\x85)",
899
	"\xc7\x85" => "(\xc7\x85|\xc7\x84|\xc7\x86)",
900
	"\xc7\x87" => "(\xc7\x87|\xc7\x89|\xc7\x88)",
901
	"\xc7\x88" => "(\xc7\x88|\xc7\x87|\xc7\x89)",
902
	"\xc7\x8a" => "(\xc7\x8a|\xc7\x8c|\xc7\x8b)",
903
	"\xc7\x8b" => "(\xc7\x8b|\xc7\x8a|\xc7\x8c)",
906 904
	"\xc7\x8d" => "(\xc7\x8d|\xc7\x8e)",
907 905
	"\xc7\x8f" => "(\xc7\x8f|\xc7\x90)",
908 906
	"\xc7\x91" => "(\xc7\x91|\xc7\x92)",
......
920 918
	"\xc7\xaa" => "(\xc7\xaa|\xc7\xab)",
921 919
	"\xc7\xac" => "(\xc7\xac|\xc7\xad)",
922 920
	"\xc7\xae" => "(\xc7\xae|\xc7\xaf)",
923
	"\xc7\xb1" => "(\xc7\xb1|\xc7\xb3)",
924
	"\xc7\xb2" => "(\xc7\xb2|\xc7\xb3)",
921
	"\xc7\xb1" => "(\xc7\xb1|\xc7\xb3|\xc7\xb2)",
925 922
	"\xc7\xb4" => "(\xc7\xb4|\xc7\xb5)",
926 923
	"\xc7\xb6" => "(\xc7\xb6|\xc6\x95)",
927 924
	"\xc7\xb7" => "(\xc7\xb7|\xc6\xbf)",
......
962 959
	"\xce\x8e" => "(\xce\x8e|\xcf\x8d)",
963 960
	"\xce\x8f" => "(\xce\x8f|\xcf\x8e)",
964 961
	"\xce\x91" => "(\xce\x91|\xce\xb1)",
965
	"\xce\x92" => "(\xce\x92|\xce\xb2)",
962
	"\xce\x92" => "(\xce\x92|\xce\xb2|\xcf\x90)",
966 963
	"\xce\x93" => "(\xce\x93|\xce\xb3)",
967 964
	"\xce\x94" => "(\xce\x94|\xce\xb4)",
968
	"\xce\x95" => "(\xce\x95|\xce\xb5)",
965
	"\xce\x95" => "(\xce\x95|\xce\xb5|\xcf\xb5)",
969 966
	"\xce\x96" => "(\xce\x96|\xce\xb6)",
970 967
	"\xce\x97" => "(\xce\x97|\xce\xb7)",
971
	"\xce\x98" => "(\xce\x98|\xce\xb8)",
972
	"\xce\x99" => "(\xce\x99|\xce\xb9)",
973
	"\xce\x9a" => "(\xce\x9a|\xce\xba)",
968
	"\xce\x98" => "(\xce\x98|\xce\xb8|\xcf\x91)",
969
	"\xce\x99" => "(\xce\x99|\xce\xb9|\xcd\x85|\xe1\xbe\xbe)",
970
	"\xce\x9a" => "(\xce\x9a|\xce\xba|\xcf\xb0)",
974 971
	"\xce\x9b" => "(\xce\x9b|\xce\xbb)",
975
	"\xce\x9c" => "(\xce\x9c|\xce\xbc)",
972
	"\xce\x9c" => "(\xce\x9c|\xce\xbc|\xc2\xb5)",
976 973
	"\xce\x9d" => "(\xce\x9d|\xce\xbd)",
977 974
	"\xce\x9e" => "(\xce\x9e|\xce\xbe)",
978 975
	"\xce\x9f" => "(\xce\x9f|\xce\xbf)",
979
	"\xce\xa0" => "(\xce\xa0|\xcf\x80)",
980
	"\xce\xa1" => "(\xce\xa1|\xcf\x81)",
981
	"\xce\xa3" => "(\xce\xa3|\xcf\x83)",
976
	"\xce\xa0" => "(\xce\xa0|\xcf\x80|\xcf\x96)",
977
	"\xce\xa1" => "(\xce\xa1|\xcf\x81|\xcf\xb1)",
978
	"\xce\xa3" => "(\xce\xa3|\xcf\x83|\xcf\x82|\xcf\xb2)",
982 979
	"\xce\xa4" => "(\xce\xa4|\xcf\x84)",
983 980
	"\xce\xa5" => "(\xce\xa5|\xcf\x85)",
984
	"\xce\xa6" => "(\xce\xa6|\xcf\x86)",
981
	"\xce\xa6" => "(\xce\xa6|\xcf\x86|\xcf\x95)",
985 982
	"\xce\xa7" => "(\xce\xa7|\xcf\x87)",
986 983
	"\xce\xa8" => "(\xce\xa8|\xcf\x88)",
987 984
	"\xce\xa9" => "(\xce\xa9|\xcf\x89)",
......
1200 1197
	"\xe1\xb9\x9a" => "(\xe1\xb9\x9a|\xe1\xb9\x9b)",
1201 1198
	"\xe1\xb9\x9c" => "(\xe1\xb9\x9c|\xe1\xb9\x9d)",
1202 1199
	"\xe1\xb9\x9e" => "(\xe1\xb9\x9e|\xe1\xb9\x9f)",
1203
	"\xe1\xb9\xa0" => "(\xe1\xb9\xa0|\xe1\xb9\xa1)",
1200
	"\xe1\xb9\xa0" => "(\xe1\xb9\xa0|\xe1\xb9\xa1|\xe1\xba\x9b)",
1204 1201
	"\xe1\xb9\xa2" => "(\xe1\xb9\xa2|\xe1\xb9\xa3)",
1205 1202
	"\xe1\xb9\xa4" => "(\xe1\xb9\xa4|\xe1\xb9\xa5)",
1206 1203
	"\xe1\xb9\xa6" => "(\xe1\xb9\xa6|\xe1\xb9\xa7)",
......
1476 1473
	"\xf0\x90\x90\xa2" => "(\xf0\x90\x90\xa2|\xf0\x90\x91\x8a)",
1477 1474
	"\xf0\x90\x90\xa3" => "(\xf0\x90\x90\xa3|\xf0\x90\x91\x8b)",
1478 1475
	"\xf0\x90\x90\xa4" => "(\xf0\x90\x90\xa4|\xf0\x90\x91\x8c)",
1479
	"\xf0\x90\x90\xa5" => "(\xf0\x90\x90\xa5|\xf0\x90\x91\x8d)"
1476
	"\xf0\x90\x90\xa5" => "(\xf0\x90\x90\xa5|\xf0\x90\x91\x8d)",
1477
	"i" => "(i|\xc4\xb0|I)",
1478
	"I" => "(I|\xc4\xb1|i)",
1479
	"k" => "(k|\xe2\x84\xaa|K)",
1480
	"S" => "(S|\xc5\xbf|s)"
1480 1481
);
1481 1482

  
1482 1483
?>
branches/2.6.x/wb/framework/frontend.functions.php
71 71
	require_once(WB_PATH.'/framework/functions.php');
72 72
	require(WB_PATH.'/search/search_convert.php');
73 73
	$foo = entities_to_umlauts($foo, 'UTF-8');
74
	foreach($arr_string as $string) {
75
		$string = strtr($string, $string_htmlspecialchars_decode);
76
		$string = entities_to_umlauts($string, 'UTF-8');
77
		$string = preg_quote($string, '/');
78
		$string = strtr($string, $string_ul_umlauts);
79
		$foo = preg_replace('/('.$string.')(?=[^>]*<)/iUS', '<span class="highlight">$1</span>',$foo);
80
		$pos = strpos($foo, '<');
81
		if ($pos === false) { // "===" means identicaly
82
			$foo = preg_replace('/('.$string.')/i', '<span class="highlight">$1</span>',$foo);
83
		}
74
	array_walk($arr_string, create_function('&$v,$k','$v = preg_quote($v, \'/\');'));
75
	$search_string = implode("|", $arr_string);
76
	$string = entities_to_umlauts($search_string, 'UTF-8');
77
	$string = strtr($string, $string_ul_umlauts);
78
	$foo = preg_replace('/('.$string.')(?=[^>]*<)/iUS', '<span class="highlight">$1</span>',$foo);
79
	$pos = strpos($foo, '<');
80
	if ($pos === false) { // "===" means identicaly
81
		$foo = preg_replace('/('.$string.')/i', '<span class="highlight">$1</span>',$foo);
84 82
	}
85 83
	$foo = umlauts_to_entities($foo, 'UTF-8', 0);
86 84
	return $foo;
branches/2.6.x/wb/framework/functions.php
340 340

  
341 341
// Function as replecement for php's htmlspecialchars()
342 342
function my_htmlspecialchars($string) {
343
	$string = strtr($string, array("<"=>"&lt;", ">"=>"&gt;", "\""=>"&quot;", "\'"=>"&#039;"));
343
	$string = preg_replace("/&(?=[#a-z0-9]+;)/i", "_x_", $string);
344
	$string = strtr($string, array("<"=>"&lt;", ">"=>"&gt;", "&"=>"&amp;", "\""=>"&quot;", "\'"=>"&#039;"));
345
	$string = preg_replace("/_x_(?=[#a-z0-9]+;)/i", "&", $string);
344 346
	return($string);
345 347
}
346 348

  
......
369 371
	if ($charset_out == $charset_in) {
370 372
		return $string;
371 373
	}
374
	$use_iconv = true;
375
	$use_mbstring = true;
376
	if(version_compare(PHP_VERSION, "5.1.0", "<")) {
377
		$use_mbstring = false; // don't rely on mb_convert_encoding if php<5.1.0
378
		$use_iconv = false; // don't rely on iconv neither
379
	}
380
	
372 381
	// try mb_convert_encoding(). This can handle to or from HTML-ENTITIES, too
373
	if (function_exists('mb_convert_encoding')) {
382
	if ($use_mbstring && function_exists('mb_convert_encoding')) {
374 383
		// there's no GB2312 or ISO-8859-11 encoding in php's mb_* functions
375 384
		if ($charset_in=='ISO-8859-11' || $charset_in=='GB2312') {
376
			if (function_exists('iconv')) {
385
			if ($use_iconv && function_exists('iconv')) {
377 386
				$string = iconv($charset_in, 'UTF-8', $string);
378 387
			}
379 388
			else {
......
390 399
		}
391 400
		if ($charset_out=='ISO-8859-11' || $charset_out=='GB2312') {
392 401
			$string=mb_convert_encoding($string, 'UTF-8', $charset_in);
393
			if (function_exists('iconv')) {
402
			if ($use_iconv && function_exists('iconv')) {
394 403
				$string = iconv('UTF-8', $charset_out, $string);
395 404
			}
396 405
			else {
......
409 418
	}
410 419

  
411 420
	// try iconv(). This can't handle to or from HTML-ENTITIES.
412
	if (function_exists('iconv') && $charset_out!='HTML-ENTITIES' && $charset_in!='HTML-ENTITIES' ) {
421
	if ($use_iconv && function_exists('iconv') && $charset_out!='HTML-ENTITIES' && $charset_in!='HTML-ENTITIES' ) {
413 422
		$string = iconv($charset_in, $charset_out, $string);
414 423
		return $string;
415 424
	}
416 425

  
417
	// do the UTF-8->HTML-ENTITIES or HTML-ENTITIES->UTF-8 translation
426
	// do the UTF-8->HTML-ENTITIES or HTML-ENTITIES->UTF-8 translation if mb_convert_encoding isn't available
418 427
	if (($charset_in=='HTML-ENTITIES' && $charset_out=='UTF-8') || ($charset_in=='UTF-8' && $charset_out=='HTML-ENTITIES')) {
419
		$named_to_numbered_entities=array(
420
			'&nbsp;'=>'&#160;','&iexcl;'=>'&#161;','&cent;'=>'&#162;','&pound;'=>'&#163;','&curren;'=>'&#164;',
421
			'&yen;'=>'&#165;','&brvbar;'=>'&#166;','&sect;'=>'&#167;','&uml;'=>'&#168;','&ordf;'=>'&#170;',
422
			'&laquo;'=>'&#171;','&not;'=>'&#172;','&shy;'=>'&#173;','&reg;'=>'&#174;','&macr;'=>'&#175;',
423
			'&deg;'=>'&#176;','&plusmn;'=>'&#177;','&sup2;'=>'&#178;','&sup3;'=>'&#179;','&acute;'=>'&#180;',
424
			'&micro;'=>'&#181;','&para;'=>'&#182;','&middot;'=>'&#183;','&cedil;'=>'&#184;','&sup1;'=>'&#185;',
425
			'&ordm;'=>'&#186;','&raquo;'=>'&#187;','&frac14;'=>'&#188;','&frac12;'=>'&#189;','&frac34;'=>'&#190;',
426
			'&iquest;'=>'&#191;','&divide;'=>'&#247;','&empty;'=>'&#8709;','&euro;'=>'&#8364;',
427
			'&Aacute;'=>'&#193;','&aacute;'=>'&#225;','&Acirc;'=>'&#194;',
428
			'&acirc;'=>'&#226;','&AElig;'=>'&#198;','&aelig;'=>'&#230;','&Agrave;'=>'&#192;','&agrave;'=>'&#224;',
429
			'&Aring;'=>'&#197;','&aring;'=>'&#229;','&Atilde;'=>'&#195;','&atilde;'=>'&#227;','&Auml;'=>'&#196;',
430
			'&auml;'=>'&#228;','&Ccedil;'=>'&#199;','&ccedil;'=>'&#231;','&Eacute;'=>'&#201;','&eacute;'=>'&#233;',
431
			'&Ecirc;'=>'&#202;','&ecirc;'=>'&#234;','&Egrave;'=>'&#200;','&egrave;'=>'&#232;','&Euml;'=>'&#203;',
432
			'&euml;'=>'&#235;','&Iacute;'=>'&#205;','&iacute;'=>'&#237;','&Icirc;'=>'&#206;','&icirc;'=>'&#238;',
433
			'&Igrave;'=>'&#204;','&igrave;'=>'&#236;','&Iuml;'=>'&#207;','&iuml;'=>'&#239;','&Ntilde;'=>'&#209;',
434
			'&ntilde;'=>'&#241;','&Oacute;'=>'&#211;','&oacute;'=>'&#243;','&Ocirc;'=>'&#212;','&ocirc;'=>'&#244;',
435
			'&OElig;'=>'&#338;','&oelig;'=>'&#339;','&Ograve;'=>'&#210;','&ograve;'=>'&#242;','&Otilde;'=>'&#213;',
436
			'&otilde;'=>'&#245;','&Ouml;'=>'&#214;','&ouml;'=>'&#246;','&Scaron;'=>'&#352;','&scaron;'=>'&#353;',
437
			'&szlig;'=>'&#223;','&Uacute;'=>'&#218;','&uacute;'=>'&#250;','&Ucirc;'=>'&#219;','&ucirc;'=>'&#251;',
438
			'&Ugrave;'=>'&#217;','&ugrave;'=>'&#249;','&Uuml;'=>'&#220;','&uuml;'=>'&#252;','&Yacute;'=>'&#221;',
439
			'&yacute;'=>'&#253;','&Yuml;'=>'&#376;','&yuml;'=>'&#255;','&copy;'=>'&#169;','&reg;'=>'&#174;',
440
			'&ETH;'=>'&#208;','&times;'=>'&#215;','&Oslash;'=>'&#216;','&THORN;'=>'&#222;','&eth;'=>'&#240;',
441
			'&oslash;'=>'&#248;','&thorn;'=>'&#254;');
442
		$numbered_to_named_entities=array('&#193;'=>'&Aacute;','&#225;'=>'&aacute;','&#194;'=>'&Acirc;',
443
			'&#160;'=>'&nbsp;','&#161;'=>'&iexcl;','&#162;'=>'&cent;','&#163;'=>'&pound;','&#164;'=>'&curren;',
444
			'&#165;'=>'&yen;','&#166;'=>'&brvbar;','&#167;'=>'&sect;','&#168;'=>'&uml;','&#170;'=>'&ordf;',
445
			'&#171;'=>'&laquo;','&#172;'=>'&not;','&#173;'=>'&shy;','&#174;'=>'&reg;','&#175;'=>'&macr;',
446
			'&#176;'=>'&deg;','&#177;'=>'&plusmn;','&#178;'=>'&sup2;','&#179;'=>'&sup3;','&#180;'=>'&acute;',
447
			'&#181;'=>'&micro;','&#182;'=>'&para;','&#183;'=>'&middot;','&#184;'=>'&cedil;','&#185;'=>'&sup1;',
448
			'&#186;'=>'&ordm;','&#187;'=>'&raquo;','&#188;'=>'&frac14;','&#189;'=>'&frac12;','&#190;'=>'&frac34;',
449
			'&#191;'=>'&iquest;','&#247;'=>'&divide;','&#8709;'=>'&empty;','&#8364;'=>'&euro;',
450
			'&#226;'=>'&acirc;','&#198;'=>'&AElig;','&#230;'=>'&aelig;','&#192;'=>'&Agrave;','&#224;'=>'&agrave;',
451
			'&#197;'=>'&Aring;','&#229;'=>'&aring;','&#195;'=>'&Atilde;','&#227;'=>'&atilde;','&#196;'=>'&Auml;',
452
			'&#228;'=>'&auml;','&#199;'=>'&Ccedil;','&#231;'=>'&ccedil;','&#201;'=>'&Eacute;','&#233;'=>'&eacute;',
453
			'&#202;'=>'&Ecirc;','&#234;'=>'&ecirc;','&#200;'=>'&Egrave;','&#232;'=>'&egrave;','&#203;'=>'&Euml;',
454
			'&#235;'=>'&euml;','&#205;'=>'&Iacute;','&#237;'=>'&iacute;','&#206;'=>'&Icirc;','&#238;'=>'&icirc;',
455
			'&#204;'=>'&Igrave;','&#236;'=>'&igrave;','&#207;'=>'&Iuml;','&#239;'=>'&iuml;','&#209;'=>'&Ntilde;',
456
			'&#241;'=>'&ntilde;','&#211;'=>'&Oacute;','&#243;'=>'&oacute;','&#212;'=>'&Ocirc;','&#244;'=>'&ocirc;',
457
			'&#338;'=>'&OElig;','&#339;'=>'&oelig;','&#210;'=>'&Ograve;','&#242;'=>'&ograve;','&#213;'=>'&Otilde;',
458
			'&#245;'=>'&otilde;','&#214;'=>'&Ouml;','&#246;'=>'&ouml;','&#352;'=>'&Scaron;','&#353;'=>'&scaron;',
459
			'&#223;'=>'&szlig;','&#218;'=>'&Uacute;','&#250;'=>'&uacute;','&#219;'=>'&Ucirc;','&#251;'=>'&ucirc;',
460
			'&#217;'=>'&Ugrave;','&#249;'=>'&ugrave;','&#220;'=>'&Uuml;','&#252;'=>'&uuml;','&#221;'=>'&Yacute;',
461
			'&#253;'=>'&yacute;','&#376;'=>'&Yuml;','&#255;'=>'&yuml;','&#169;'=>'&copy;','&#174;'=>'&reg;',
462
			'&#208;'=>'&ETH;','&#215;'=>'&times;','&#216;'=>'&Oslash;','&#222;'=>'&THORN;','&#240;'=>'&eth;',
463
			'&#248;'=>'&oslash;','&#254;'=>'&thorn;');
464
		if ($charset_in == 'HTML-ENTITIES') {
465
			$string = strtr($string, $named_to_numbered_entities);
466
			$string = preg_replace("/&#([0-9]+);/e", "code_to_utf8($1)", $string);
467
		}
468
		elseif ($charset_out == 'HTML-ENTITIES') {
469
			$string = preg_replace("/&#([0-9]+);/e", "code_to_utf8($1)", $string);
470
			$char = "";
471
			while (strlen($string) > 0) {
472
				preg_match("/^(.)(.*)$/su", $string, $match);
473
				if (strlen($match[1]) > 1) {
474
					$char .= "&#".uniord($match[1]).";";
475
				} else $char .= $match[1];
476
				$string = $match[2];
477
			}
478
			$string = $char;
479
			$string = strtr($string, $numbered_to_named_entities);
480
		}
428
		$string = string_decode_encode_entities($string, $charset_out, $charset_in);
481 429
		return $string;
482 430
	}
483 431

  
......
530 478
	// and mbstring _and_ iconv aren't available.
531 479
	return $string;
532 480
}
533
// support-function for mb_convert_encoding_wrapper()
481

  
482
// Decodes or encodes html-entities. Works for utf-8 only!
483
function string_decode_encode_entities($string, $out='HTML-ENTITIES', $in='UTF-8') {
484
	if(!(($in=='UTF-8' || $in=='HTML-ENTITIES') && ($out=='UTF-8' || $out=='HTML-ENTITIES'))) {
485
		return $string;
486
	}
487
	$named_to_numbered_entities=array(
488
		'&Aacute;'=>'&#193;','&aacute;'=>'&#225;',
489
		'&Acirc;'=>'&#194;','&acirc;'=>'&#226;','&acute;'=>'&#180;','&AElig;'=>'&#198;','&aelig;'=>'&#230;',
490
		'&Agrave;'=>'&#192;','&agrave;'=>'&#224;','&alefsym;'=>'&#8501;','&Alpha;'=>'&#913;','&alpha;'=>'&#945;',
491
		'&amp;'=>'&#38;','&and;'=>'&#8743;','&ang;'=>'&#8736;','&apos;'=>'&#39;','&Aring;'=>'&#197;','&aring;'=>'&#229;',
492
		'&asymp;'=>'&#8776;','&Atilde;'=>'&#195;','&atilde;'=>'&#227;','&Auml;'=>'&#196;','&auml;'=>'&#228;',
493
		'&bdquo;'=>'&#8222;','&Beta;'=>'&#914;','&beta;'=>'&#946;','&brvbar;'=>'&#166;','&bull;'=>'&#8226;',
494
		'&cap;'=>'&#8745;','&Ccedil;'=>'&#199;','&ccedil;'=>'&#231;','&cedil;'=>'&#184;','&cent;'=>'&#162;',
495
		'&Chi;'=>'&#935;','&chi;'=>'&#967;','&circ;'=>'&#710;','&clubs;'=>'&#9827;','&cong;'=>'&#8773;',
496
		'&copy;'=>'&#169;','&crarr;'=>'&#8629;','&cup;'=>'&#8746;','&curren;'=>'&#164;','&Dagger;'=>'&#8225;',
497
		'&dagger;'=>'&#8224;','&dArr;'=>'&#8659;','&darr;'=>'&#8595;','&deg;'=>'&#176;','&Delta;'=>'&#916;',
498
		'&delta;'=>'&#948;','&diams;'=>'&v#9830;','&divide;'=>'&#247;','&Eacute;'=>'&#201;','&eacute;'=>'&#233;',
499
		'&Ecirc;'=>'&#202;','&ecirc;'=>'&#234;','&Egrave;'=>'&#200;','&egrave;'=>'&#232;','&empty;'=>'&#8709;',
500
		'&emsp;'=>'&#8195;','&ensp;'=>'&#8194;','&Epsilon;'=>'&#917;','&epsilon;'=>'&#949;','&equiv;'=>'&#8801;',
501
		'&Eta;'=>'&#919;','&eta;'=>'&#951;','&ETH;'=>'&#208;','&eth;'=>'&#240;','&Euml;'=>'&#203;','&euml;'=>'&#235;',
502
		'&euro;'=>'&#8364;','&exist;'=>'&#8707;','&fnof;'=>'&#402;','&forall;'=>'&#8704;','&frac12;'=>'&#189;',
503
		'&frac14;'=>'&#188;','&frac34;'=>'&#190;','&frasl;'=>'&#8260;','&Gamma;'=>'&#915;','&gamma;'=>'&#947;',
504
		'&ge;'=>'&#8805;','&gt;'=>'&#62;','&hArr;'=>'&#8660;','&harr;'=>'&#8596;','&hearts;'=>'&#9829;',
505
		'&hellip;'=>'&#8230;','&Iacute;'=>'&#205;','&iacute;'=>'&#237;','&Icirc;'=>'&#206;','&icirc;'=>'&#238;',
506
		'&iexcl;'=>'&#161;','&Igrave;'=>'&#204;','&igrave;'=>'&#236;','&image;'=>'&#8465;','&infin;'=>'&#8734;',
507
		'&int;'=>'&#8747;','&Iota;'=>'&#921;','&iota;'=>'&#953;','&iquest;'=>'&#191;','&isin;'=>'&#8712;',
508
		'&Iuml;'=>'&#207;','&iuml;'=>'&#239;','&Kappa;'=>'&#922;','&kappa;'=>'&#954;','&Lambda;'=>'&#923;',
509
		'&lambda;'=>'&#955;','&lang;'=>'&#9001;','&laquo;'=>'&#171;','&lArr;'=>'&#8656;','&larr;'=>'&#8592;',
510
		'&lceil;'=>'&#8968;','&ldquo;'=>'&#8220;','&le;'=>'&#8804;','&lfloor;'=>'&#8970;','&lowast;'=>'&#8727;',
511
		'&loz;'=>'&#9674;','&lrm;'=>'&#8206;','&lsaquo;'=>'&#8249;','&lsquo;'=>'&#8216;','&lt;'=>'&#60;',
512
		'&macr;'=>'&#175;','&mdash;'=>'&#8212;','&micro;'=>'&#181;','&middot;'=>'&#183;','&minus;'=>'&#8722;',
513
		'&Mu;'=>'&#924;','&mu;'=>'&#956;','&nabla;'=>'&#8711;','&nbsp;'=>'&#160;','&ndash;'=>'&#8211;',
514
		'&ne;'=>'&#8800;','&ni;'=>'&#8715;','&not;'=>'&#172;','&notin;'=>'&#8713;','&nsub;'=>'&#8836;',
515
		'&Ntilde;'=>'&#209;','&ntilde;'=>'&#241;','&Nu;'=>'&#925;','&nu;'=>'&#957;','&Oacute;'=>'&#211;',
516
		'&oacute;'=>'&#243;','&Ocirc;'=>'&#212;','&ocirc;'=>'&#244;','&OElig;'=>'&#338;','&oelig;'=>'&#339;',
517
		'&Ograve;'=>'&#210;','&ograve;'=>'&#242;','&oline;'=>'&#8254;','&Omega;'=>'&#937;','&omega;'=>'&#969;',
518
		'&Omicron;'=>'&#927;','&omicron;'=>'&#959;','&oplus;'=>'&#8853;','&or;'=>'&#8744;','&ordf;'=>'&#170;',
519
		'&ordm;'=>'&#186;','&Oslash;'=>'&#216;','&oslash;'=>'&#248;','&Otilde;'=>'&#213;','&otilde;'=>'&#245;',
520
		'&otimes;'=>'&#8855;','&Ouml;'=>'&#214;','&ouml;'=>'&#246;','&para;'=>'&#182;','&part;'=>'&#8706;',
521
		'&permil;'=>'&#8240;','&perp;'=>'&#8869;','&Phi;'=>'&#934;','&phi;'=>'&#966;','&Pi;'=>'&#928;',
522
		'&pi;'=>'&#960;','&piv;'=>'&#982;','&plusmn;'=>'&#177;','&pound;'=>'&#163;','&Prime;'=>'&#8243;',
523
		'&prime;'=>'&#8242;','&prod;'=>'&#8719;','&prop;'=>'&#8733;','&Psi;'=>'&#936;','&psi;'=>'&#968;',
524
		'&quot;'=>'&#34;','&radic;'=>'&#8730;','&rang;'=>'&#9002;','&raquo;'=>'&#187;','&rArr;'=>'&#8658;',
525
		'&rarr;'=>'&#8594;','&rceil;'=>'&#8969;','&rdquo;'=>'&#8221;','&real;'=>'&#8476;','&reg;'=>'&#174;',
526
		'&rfloor;'=>'&#8971;','&Rho;'=>'&#929;','&rho;'=>'&#961;','&rlm;'=>'&#8207;','&rsaquo;'=>'&#8250;',
527
		'&rsquo;'=>'&#8217;','&sbquo;'=>'&#8218;','&Scaron;'=>'&#352;','&scaron;'=>'&#353;','&sdot;'=>'&#8901;',
528
		'&sect;'=>'&#167;','&shy;'=>'&#173;','&Sigma;'=>'&#931;','&sigma;'=>'&#963;','&sigmaf;'=>'&#962;',
529
		'&sim;'=>'&#8764;','&spades;'=>'&#9824;','&sub;'=>'&#8834;','&sube;'=>'&#8838;','&sum;'=>'&#8721;',
530
		'&sup;'=>'&#8835;','&sup1;'=>'&#185;','&sup2;'=>'&#178;','&sup3;'=>'&#179;','&supe;'=>'&#8839;',
531
		'&szlig;'=>'&#223;','&Tau;'=>'&#932;','&tau;'=>'&#964;','&there4;'=>'&#8756;','&Theta;'=>'&#920;',
532
		'&theta;'=>'&#952;','&thetasym;'=>'&#977;','&thinsp;'=>'&#8201;','&THORN;'=>'&#222;','&thorn;'=>'&#254;',
533
		'&tilde;'=>'&#732;','&times;'=>'&#215;','&trade;'=>'&#8482;','&Uacute;'=>'&#218;','&uacute;'=>'&#250;',
534
		'&uArr;'=>'&#8657;','&uarr;'=>'&#8593;','&Ucirc;'=>'&#219;','&ucirc;'=>'&#251;','&Ugrave;'=>'&#217;',
535
		'&ugrave;'=>'&#249;','&uml;'=>'&#168;','&upsih;'=>'&#978;','&Upsilon;'=>'&#933;','&upsilon;'=>'&#965;',
536
		'&Uuml;'=>'&#220;','&uuml;'=>'&#252;','&weierp;'=>'&#8472;','&Xi;'=>'&#926;','&xi;'=>'&#958;',
537
		'&Yacute;'=>'&#221;','&yacute;'=>'&#253;','&yen;'=>'&#165;','&Yuml;'=>'&#376;','&yuml;'=>'&#255;',
538
		'&Zeta;'=>'&#918;','&zeta;'=>'&#950;','&zwj;'=>'&#8205;','&zwnj;'=>'&#8204;'
539
	);
540
	$numbered_to_named_entities=array(
541
		'&#193;'=>'&Aacute;','&#225;'=>'&aacute;','&#194;'=>'&Acirc;','&#226;'=>'&acirc;','&#180;'=>'&acute;',
542
		'&#198;'=>'&AElig;','&#230;'=>'&aelig;','&#192;'=>'&Agrave;','&#224;'=>'&agrave;','&#8501;'=>'&alefsym;',
543
		'&#913;'=>'&Alpha;','&#945;'=>'&alpha;','&#38;'=>'&amp;','&#8743;'=>'&and;','&#8736;'=>'&ang;',
544
		'&#39;'=>'&apos;','&#197;'=>'&Aring;','&#229;'=>'&aring;','&#8776;'=>'&asymp;','&#195;'=>'&Atilde;',
545
		'&#227;'=>'&atilde;','&#196;'=>'&Auml;','&#228;'=>'&auml;','&#8222;'=>'&bdquo;','&#914;'=>'&Beta;',
546
		'&#946;'=>'&beta;','&#166;'=>'&brvbar;','&#8226;'=>'&bull;','&#8745;'=>'&cap;','&#199;'=>'&Ccedil;',
547
		'&#231;'=>'&ccedil;','&#184;'=>'&cedil;','&#162;'=>'&cent;','&#935;'=>'&Chi;','&#967;'=>'&chi;',
548
		'&#710;'=>'&circ;','&#9827;'=>'&clubs;','&#8773;'=>'&cong;','&#169;'=>'&copy;','&#8629;'=>'&crarr;',
549
		'&#8746;'=>'&cup;','&#164;'=>'&curren;','&#8225;'=>'&Dagger;','&#8224;'=>'&dagger;','&#8659;'=>'&dArr;',
550
		'&#8595;'=>'&darr;','&#176;'=>'&deg;','&#916;'=>'&Delta;','&#948;'=>'&delta;','&v#9830;'=>'&diams;',
551
		'&#247;'=>'&divide;','&#201;'=>'&Eacute;','&#233;'=>'&eacute;','&#202;'=>'&Ecirc;','&#234;'=>'&ecirc;',
552
		'&#200;'=>'&Egrave;','&#232;'=>'&egrave;','&#8709;'=>'&empty;','&#8195;'=>'&emsp;','&#8194;'=>'&ensp;',
553
		'&#917;'=>'&Epsilon;','&#949;'=>'&epsilon;','&#8801;'=>'&equiv;','&#919;'=>'&Eta;','&#951;'=>'&eta;',
554
		'&#208;'=>'&ETH;','&#240;'=>'&eth;','&#203;'=>'&Euml;','&#235;'=>'&euml;','&#8364;'=>'&euro;',
555
		'&#8707;'=>'&exist;','&#402;'=>'&fnof;','&#8704;'=>'&forall;','&#189;'=>'&frac12;','&#188;'=>'&frac14;',
556
		'&#190;'=>'&frac34;','&#8260;'=>'&frasl;','&#915;'=>'&Gamma;','&#947;'=>'&gamma;','&#8805;'=>'&ge;',
557
		'&#62;'=>'&gt;','&#8660;'=>'&hArr;','&#8596;'=>'&harr;','&#9829;'=>'&hearts;','&#8230;'=>'&hellip;',
558
		'&#205;'=>'&Iacute;','&#237;'=>'&iacute;','&#206;'=>'&Icirc;','&#238;'=>'&icirc;','&#161;'=>'&iexcl;',
559
		'&#204;'=>'&Igrave;','&#236;'=>'&igrave;','&#8465;'=>'&image;','&#8734;'=>'&infin;','&#8747;'=>'&int;',
560
		'&#921;'=>'&Iota;','&#953;'=>'&iota;','&#191;'=>'&iquest;','&#8712;'=>'&isin;','&#207;'=>'&Iuml;',
561
		'&#239;'=>'&iuml;','&#922;'=>'&Kappa;','&#954;'=>'&kappa;','&#923;'=>'&Lambda;','&#955;'=>'&lambda;',
562
		'&#9001;'=>'&lang;','&#171;'=>'&laquo;','&#8656;'=>'&lArr;','&#8592;'=>'&larr;','&#8968;'=>'&lceil;',
563
		'&#8220;'=>'&ldquo;','&#8804;'=>'&le;','&#8970;'=>'&lfloor;','&#8727;'=>'&lowast;','&#9674;'=>'&loz;',
564
		'&#8206;'=>'&lrm;','&#8249;'=>'&lsaquo;','&#8216;'=>'&lsquo;','&#60;'=>'&lt;','&#175;'=>'&macr;',
565
		'&#8212;'=>'&mdash;','&#181;'=>'&micro;','&#183;'=>'&middot;','&#8722;'=>'&minus;','&#924;'=>'&Mu;',
566
		'&#956;'=>'&mu;','&#8711;'=>'&nabla;','&#160;'=>'&nbsp;','&#8211;'=>'&ndash;','&#8800;'=>'&ne;',
567
		'&#8715;'=>'&ni;','&#172;'=>'&not;','&#8713;'=>'&notin;','&#8836;'=>'&nsub;','&#209;'=>'&Ntilde;',
568
		'&#241;'=>'&ntilde;','&#925;'=>'&Nu;','&#957;'=>'&nu;','&#211;'=>'&Oacute;','&#243;'=>'&oacute;',
569
		'&#212;'=>'&Ocirc;','&#244;'=>'&ocirc;','&#338;'=>'&OElig;','&#339;'=>'&oelig;','&#210;'=>'&Ograve;',
570
		'&#242;'=>'&ograve;','&#8254;'=>'&oline;','&#937;'=>'&Omega;','&#969;'=>'&omega;','&#927;'=>'&Omicron;',
571
		'&#959;'=>'&omicron;','&#8853;'=>'&oplus;','&#8744;'=>'&or;','&#170;'=>'&ordf;','&#186;'=>'&ordm;',
572
		'&#216;'=>'&Oslash;','&#248;'=>'&oslash;','&#213;'=>'&Otilde;','&#245;'=>'&otilde;','&#8855;'=>'&otimes;',
573
		'&#214;'=>'&Ouml;','&#246;'=>'&ouml;','&#182;'=>'&para;','&#8706;'=>'&part;','&#8240;'=>'&permil;',
574
		'&#8869;'=>'&perp;','&#934;'=>'&Phi;','&#966;'=>'&phi;','&#928;'=>'&Pi;','&#960;'=>'&pi;','&#982;'=>'&piv;',
575
		'&#177;'=>'&plusmn;','&#163;'=>'&pound;','&#8243;'=>'&Prime;','&#8242;'=>'&prime;','&#8719;'=>'&prod;',
576
		'&#8733;'=>'&prop;','&#936;'=>'&Psi;','&#968;'=>'&psi;','&#34;'=>'&quot;','&#8730;'=>'&radic;',
577
		'&#9002;'=>'&rang;','&#187;'=>'&raquo;','&#8658;'=>'&rArr;','&#8594;'=>'&rarr;','&#8969;'=>'&rceil;',
578
		'&#8221;'=>'&rdquo;','&#8476;'=>'&real;','&#174;'=>'&reg;','&#8971;'=>'&rfloor;','&#929;'=>'&Rho;',
579
		'&#961;'=>'&rho;','&#8207;'=>'&rlm;','&#8250;'=>'&rsaquo;','&#8217;'=>'&rsquo;','&#8218;'=>'&sbquo;',
580
		'&#352;'=>'&Scaron;','&#353;'=>'&scaron;','&#8901;'=>'&sdot;','&#167;'=>'&sect;','&#173;'=>'&shy;',
581
		'&#931;'=>'&Sigma;','&#963;'=>'&sigma;','&#962;'=>'&sigmaf;','&#8764;'=>'&sim;','&#9824;'=>'&spades;',
582
		'&#8834;'=>'&sub;','&#8838;'=>'&sube;','&#8721;'=>'&sum;','&#8835;'=>'&sup;','&#185;'=>'&sup1;',
583
		'&#178;'=>'&sup2;','&#179;'=>'&sup3;','&#8839;'=>'&supe;','&#223;'=>'&szlig;','&#932;'=>'&Tau;',
584
		'&#964;'=>'&tau;','&#8756;'=>'&there4;','&#920;'=>'&Theta;','&#952;'=>'&theta;','&#977;'=>'&thetasym;',
585
		'&#8201;'=>'&thinsp;','&#222;'=>'&THORN;','&#254;'=>'&thorn;','&#732;'=>'&tilde;','&#215;'=>'&times;',
586
		'&#8482;'=>'&trade;','&#218;'=>'&Uacute;','&#250;'=>'&uacute;','&#8657;'=>'&uArr;','&#8593;'=>'&uarr;',
587
		'&#219;'=>'&Ucirc;','&#251;'=>'&ucirc;','&#217;'=>'&Ugrave;','&#249;'=>'&ugrave;','&#168;'=>'&uml;',
588
		'&#978;'=>'&upsih;','&#933;'=>'&Upsilon;','&#965;'=>'&upsilon;','&#220;'=>'&Uuml;','&#252;'=>'&uuml;',
589
		'&#8472;'=>'&weierp;','&#926;'=>'&Xi;','&#958;'=>'&xi;','&#221;'=>'&Yacute;','&#253;'=>'&yacute;',
590
		'&#165;'=>'&yen;','&#376;'=>'&Yuml;','&#255;'=>'&yuml;','&#918;'=>'&Zeta;','&#950;'=>'&zeta;','&#8205;'=>'&zwj;',
591
		'&#8204;'=>'&zwnj;'
592
	);
593
		
594
	if ($in == 'HTML-ENTITIES') {
595
		$string = strtr($string, $named_to_numbered_entities);
596
		$string = preg_replace("/&#([0-9]+);/e", "code_to_utf8($1)", $string);
597
	}
598
	elseif ($out == 'HTML-ENTITIES') {
599
		//$string = preg_replace("/&#([0-9]+);/e", "code_to_utf8($1)", $string);
600
		$char = "";
601
		while (strlen($string) > 0) {
602
			preg_match("/^(.)(.*)$/su", $string, $match);
603
			if (strlen($match[1]) > 1) {
604
				$char .= "&#".uniord($match[1]).";";
605
			} else $char .= $match[1];
606
			$string = $match[2];
607
		}
608
		$string = $char;
609
		$string = strtr($string, $numbered_to_named_entities);
610
	}
611
	return $string;
612
}
613

  
614
// support-function for string_decode_encode_entities()
534 615
function uniord($c) {
535 616
        $ud = 0;
536 617
        if (ord($c{0}) >= 0 && ord($c{0}) <= 127) $ud = ord($c{0});
......
604 685
function entities_to_umlauts($string, $charset_out=DEFAULT_CHARSET, $convert_htmlspecialchars=0) {
605 686
	$charset_out = strtoupper($charset_out);
606 687
	if ($charset_out == '') { $charset_out = 'ISO-8859-1'; }
607
	$string = string_to_utf8($string);
608
	if($charset_out!='UTF-8' && is_UTF8($string)) {
688
	$charset_in = strtoupper(DEFAULT_CHARSET);
689
	
690
	// string to utf-8
691
	if ($charset_in == 'ISO-8859-1' || $charset_in == 'UTF-8') {
692
		if ($charset_in == 'ISO-8859-1') {
693
			$string=utf8_encode($string);
694
		}
695
		// decode html-entities
696
		if(preg_match("/&[#a-zA-Z0-9]+;/", $string)) {
697
			$string=string_decode_encode_entities($string, 'UTF-8', 'HTML-ENTITIES');
698
		}
699
	}
700
	else {
701
		$string = string_to_utf8($string); // will decode html-entities, too.
702
	}
703
	// string to $charset_out
704
	if($charset_out == 'ISO-8859-1') {
705
			$string=utf8_decode($string);
706
	}
707
	elseif($charset_out != 'UTF-8' && is_UTF8($string)) {
609 708
		$string=mb_convert_encoding_wrapper($string, $charset_out, 'UTF-8');
610 709
	}
611
	return($string);
612
}
710
	return $string;
711
}	
613 712

  
614 713
// Function to convert a string from mixed html-entitites/$charset_in-umlauts to pure html-entities
615 714
function umlauts_to_entities($string, $charset_in=DEFAULT_CHARSET, $convert_htmlspecialchars=0) {
616 715
	$charset_in = strtoupper($charset_in);
617 716
	if ($charset_in == "") { $charset_in = 'ISO-8859-1'; }
618
	$string = string_to_utf8($string, $charset_in);
619
	if (is_UTF8($string)) {
620
		$string=mb_convert_encoding_wrapper($string,'HTML-ENTITIES','UTF-8');
717

  
718
	// string to utf-8
719
	if ($charset_in == 'ISO-8859-1' || $charset_in == 'UTF-8') {
720
		if ($charset_in == 'ISO-8859-1') {
721
			$string=utf8_encode($string);
722
		}
723
		// encode html-entities
724
		$string=string_decode_encode_entities($string, 'HTML-ENTITIES', 'UTF-8');
725
		//$string=mb_convert_encoding_wrapper($string, 'HTML-ENTITIES', 'UTF-8');
621 726
	}
622
	return($string);
727
	else {
728
		$string = string_to_utf8($string, $charset_in);
729
		// encode html-entities
730
		if (is_UTF8($string)) {
731
			$string=string_decode_encode_entities($string, 'HTML-ENTITIES', 'UTF-8');
732
			//$string=mb_convert_encoding_wrapper($string, 'HTML-ENTITIES', 'UTF-8');
733
		}
734
	}
735
	return $string;
623 736
}
624 737

  
625 738
// translate any latin/greek/cyrillic html-entities to their plain 7bit equivalents

Also available in: Unified diff