Weird Character help please

Discussion in 'Programming' started by bbrian017, Apr 16, 2009.

  1. #1
    bbrian017, Apr 16, 2009 IP
  2. Christopher

    Christopher Peon

    Messages:
    482
    Likes Received:
    21
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I took a look, something seems to be taking things like quotes and such and instead of encoding into what they should be, they are being encoded into foreign letters.

    It's actually in your html, so it must be happening in the programming script (php?) or maybe something related to the database.

    Take a look in your database. Do the entries there have the encoding like that? ’ looks like this: ’ in the code

    If they aren't in the database, you know that it's something that is happening as data is being fetched and the page is created. If they are in the database, you know it's happening when the text is being inputted into the database.

    I don't know what's causing it, but that would be how I would investigate, try to narrow down the source :)
     
    Christopher, Apr 16, 2009 IP
  3. bbrian017

    bbrian017 Well-Known Member

    Messages:
    2,990
    Likes Received:
    66
    Best Answers:
    0
    Trophy Points:
    170
    #3
    Should it be included in here or something?

    function makeUrlFriendly($input) {
    	global $db;
    
    	//$input = remove_error_creating_chars($input);
    	$output = utf8_substr($input, 0, 240);
    	$output = utf8_strtolower($output);
    		
    	$output = trim($output);	
    	$output = html_entity_decode(htmlentities($output, ENT_COMPAT, 'UTF-8'));
    
    	$output = preg_replace("/\s/e" , "_" , $output); 	// Replace spaces with underscores
    	$output = str_replace("--", "-", $output); 	 
    	$output = str_replace("/", "", $output);
    	$output = str_replace("\\", "", $output);
    	$output = str_replace("'", "", $output); 	 
    	$output = str_replace(",", "", $output); 	 
    	$output = str_replace(";", "", $output); 	 
    	$output = str_replace(":", "", $output); 	 
    	$output = str_replace(".", "-", $output); 	 
    	$output = str_replace("?", "", $output); 	 
    	$output = str_replace("=", "-", $output); 	 
    	$output = str_replace("+", "", $output); 	 
    	$output = str_replace("$", "", $output); 	 
    	$output = str_replace("&", "", $output); 	 
    	$output = str_replace("!", "", $output); 	 
    	$output = str_replace(">>", "-", $output); 	 
    	$output = str_replace(">", "-", $output); 	 
    	$output = str_replace("<<", "-", $output); 	 
    	$output = str_replace("<", "-", $output); 	 
    	$output = str_replace("*", "", $output); 	 
    	$output = str_replace(")", "", $output); 	 
    	$output = str_replace("(", "", $output);
    	$output = str_replace("[", "", $output);
    	$output = str_replace("]", "", $output);
    	$output = str_replace("^", "", $output);
    	$output = str_replace("%", "", $output);
    	$output = str_replace("»", "-", $output);
    	$output = str_replace("|", "", $output);
    	$output = str_replace("#", "", $output);
    	$output = str_replace("@", "", $output);
    	$output = str_replace("`", "", $output);
    	$output = str_replace("”", "", $output);
    	$output = str_replace("“", "", $output);
    	$output = str_replace("\"", "", $output);
    	
    	// [url]http://www.mattcutts.com/blog/dashes-vs-underscores/[/url]
    	// replace all underscores with dashes
    	$output = str_replace("_", "-", $output);  	 
    
    	if(function_exists('utils_makeUrlFriendly')) {
    		$output = utils_makeUrlFriendly($output);
    	}
       
    	// check to see if the story title already exists. If so, add an integer to the end of the title
    	$n = $db->get_var("SELECT count(*) FROM " . table_links . " WHERE link_title_url like '$output%'");
    	if ($n > 0) {
    		return $output . "-$n";}
    	else {
    		return $output;
    	}
    }
    Code (markup):
    Maybe here,

    // function makeCategoryFriendly has been moved to admin_categories.php
    
    function remove_error_creating_chars($chars) { 
    	$replace=array( 
    	'Á' => 'A',
    	'Ã…' => 'A', 
    	'ä' => 'a',
    	'á' => 'a2',
    	'à' => 'a3',
    	'â' => 'a4',
    	'ã' => 'a5',
    	'ä' => 'a',
    	'Ã¥' => 'a',
    	'æ' => 'ae',
    	'æ' => 'ae',
    	'é' => 'e',
    	'È' => 'E',
    	'É' => 'E',
    	'Ì' => 'I', 
    	'ì' => 'i', 
    	'Í' => 'I',
    	'í' => 'i',
    	'¼' => '',
    	'¾' => '',
    	'¿' => '',
    	'ñ' => 'n',
    	'Ñ' => 'N',
    	'Ã’' => 'O',
    	'ò' => 'o',
    	'Ö' => 'O',
    	'Õ' => 'O',
    	'Ó' => 'O',
    	'ô' => 'o',
    	'ó' => 'o',
    	'õ' => 'o',
    	'ö' => 'o',
    	'Å ' => 's',
    	'Å¡' => 's',
    	'Û' => 'U',
    	'Ú' => 'U',
    	'Ü' => 'U',
    	'û' => 'u',
    	'ú' => 'u',
    	'ü' => 'u',
    	'Ý' => 'Y',
    	'ý' => 'y',
    	'Ž' => 'Z', 
    	'ž' => 'z', 
    	'€' => ''
    	);
    
    	foreach ($replace as $key => $value) {
    		$chars = str_replace($key, $value, $chars );
    	}
    	return $chars;
    }
    Code (markup):
     
    bbrian017, Apr 16, 2009 IP
  4. Christopher

    Christopher Peon

    Messages:
    482
    Likes Received:
    21
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I have not been able to replicate the error with either of those codes. I don't *think* the error is occuring there, but I am NOT a php guru by any means. You need someone that really knows what they are doing to take a look.

    If a php guru doesn't jump in here and help, you might try a site that I use a lot for this type of thing, http://www.experts-exchange.com I use it so much that I joined and pay about $10/month so that I have unlimited points. Whenever I code myself into something over my head I go to them and they tell me where the problem is or even recode it for me. It's a very handy site for that type of thing.

    Wish I could help more.
     
    Christopher, Apr 16, 2009 IP
  5. bbrian017

    bbrian017 Well-Known Member

    Messages:
    2,990
    Likes Received:
    66
    Best Answers:
    0
    Trophy Points:
    170
    #5
    it's all good I simply romoved the pages in links!

    I think Google frowns upon stuff like that!

    56 pages... gone! 1358 discarded stories deleted
     
    bbrian017, Apr 16, 2009 IP