PDA

View Full Version : Removing accented UTF8 characters from URL


Morpheus NS
06-20-2011, 09:51 AM
Hello, everyone! I am using .htaccess to make my links simpler, but there is a problem.

My forum is in serbian, and I have a problem because my thread names sometimes contain accented letters (š, ć, đ, etc.). Those letters look different in URLs, or doesn't show at all. I am trying to replace them with non-accented letters (s, c, dj in this case) which are easily readable in my language. I got this code:

function google($input){
setlocale(LC_ALL, "en_US.UTF8");
$input = str_replace(array("'", "-", "đ"), array("", "", "dj"), $input);
$input = mb_convert_case($input, MB_CASE_LOWER, "UTF-8");
$input = iconv("UTF-8", "ASCII//TRANSLIT", $input);
$input = preg_replace("#[^a-zA-Z0-9]+#", "-", $input);
$input = preg_replace("#(-){2,}#", "$1", $input);
$input = trim($input, "-");
return $input;
}

which should do the trick for me, but I don't know where (in which file) do I have to put this code to work. Any idea? I am using vBulletin 4.1.1

LifesGreatestGift
06-21-2011, 11:08 PM
probably a file that has to do with creating new threads ;)

Morpheus NS
06-25-2011, 01:42 PM
class_friendly_url.php seems to be doing that part of the job. :) If I am right, where do you think I should put this code?

Videx
06-26-2011, 12:49 AM
I'm willing to bet this has been done before so you really shouldn't need to write code for it. I mean. vb has been international for years, so you can't be the first person with the problem.

Have you searched at vb.com?