Welcome Guest, Not a member yet? Register   Sign In
Accentuated characters in url
#8

[eluser]nico060475[/eluser]
I found the list here : http://ellislab.com/forums/viewthread/71139/ :-).

and I'm using a transliterate function very close to the one you gave here : http://ellislab.com/forums/viewthread/79752/#400374.

I use it as a replacement for the default url_title function.

Code:
function url_title($s, $separator = 'underscore', $chars_to_keep = '/[^a-z0-9_-]/' )
{
    // This way we don't have to mess with uppercase the rest of the time
    $s = strtolower(htmlentities(strip_tags(str_replace('?','',utf8_decode($s)))));
    
    // We don't need to capture the second group, so I made it optional || added slash for oslash
    $s = preg_replace ('/&([a-z])(?:uml|acute|grave|circ|tilde|cedil|ring|slash);/', '$1', $s);
    // remove unwanted chars
    // Weird characters that don't get caught above - also includes ðand þ, but I don't know what the best replacement for those would be.
    // While we're at it, we'll also get the http
    $s = str_replace( array('ß', 'æ', 'œ', 'http://'), array('ss', 'ae', 'oe', ''), $s);
    
    $s = html_entity_decode($s);
    
    // Normalize multiple spaces, dashes, and underscores
    $s = preg_replace( array('/\&/', '/\s+/', '/-+/', '/_+/'), ($separator=='dash')?'-':'_', $s);

    // Remove unwanted chars
    $s = preg_replace($chars_to_keep, '', $s);
    
    return $s;
}


Messages In This Thread
Accentuated characters in url - by El Forum - 06-25-2008, 01:47 AM
Accentuated characters in url - by El Forum - 06-25-2008, 02:33 AM
Accentuated characters in url - by El Forum - 06-25-2008, 03:20 AM
Accentuated characters in url - by El Forum - 06-25-2008, 03:41 AM
Accentuated characters in url - by El Forum - 09-05-2008, 08:56 AM
Accentuated characters in url - by El Forum - 09-05-2008, 09:15 AM
Accentuated characters in url - by El Forum - 09-05-2008, 09:26 AM
Accentuated characters in url - by El Forum - 09-05-2008, 09:49 AM
Accentuated characters in url - by El Forum - 09-05-2008, 10:05 AM



Theme © iAndrew 2016 - Forum software by © MyBB