Project

General

Profile

« Previous | Next » 

Revision 881

Added by thorn about 16 years ago

search: replaced most of $string_ul_umlauts (from search_convert.php) through use of preg's u-switch. Replaced strtr() by str_replace() (it's just faster). Changed ' to '

View differences:

functions-utf8.php
146 146
function utf8_fast_entities_to_umlauts($str) {
147 147
	if(UTF8_MBSTRING) {
148 148
		// we need this for use with mb_convert_encoding
149
		$str = str_replace(array('&','>','<','"',''',' '), array('&','>','<','"',''',' '), $str);
149
		$str = str_replace(array('&','>','<','"',''',' '), array('&','>','<','"',''',' '), $str);
150 150
		// we need two mb_convert_encoding()-calls - is this a bug?
151 151
		// mb_convert_encoding("öö", 'UTF-8', 'HTML-ENTITIES'); // with string in utf-8-encoding doesn't work. Result: "öö"
152 152
		// Work-around: convert all umlauts to entities first ("öö"->"öö"), then all entities to umlauts ("öö"->"öö")
......
404 404
	// missed some? - Many UTF-8-chars can't be romanized
405 405
	// convert to HTML-entities, and replace entites by hex-numbers
406 406
	$str = utf8_fast_umlauts_to_entities($str, false);
407
	$str = str_replace(''', ''', $str);
407
	$str = str_replace(''', ''', $str);
408 408
	$str = preg_replace('/&#([0-9]+);/e', "dechex('$1')",  $str);
409 409
	// maybe there are some > < ' " &   left, replace them too
410
	$entities = array('>'=>'','<'=>'','''=>'','\''=>'','"'=>'','&'=>'',' '=>' ');
411
	$str = strtr($str, $entities);
410
	$str = str_replace(array('>', '<', ''', '\'', '"', '&'), '', $str);
411
	$str = str_replace('&', '', $str);
412 412
	
413 413
	return($str);
414 414
}
......
417 417
 * Convert a string from mixed html-entities/umlauts to pure $charset_out-umlauts
418 418
 * 
419 419
 * Will replace all numeric and named entities except
420
 * > < ' " '  
420
 * > < ' " '  
421 421
 * @author thorn
422 422
 */
423 423
function entities_to_umlauts2($string, $charset_out=DEFAULT_CHARSET) {

Also available in: Unified diff