EllisLab text mark
Advanced Search
     
url_title bug
Posted: 07 October 2007 02:37 PM   [ Ignore ]
Joined: 2006-11-02
30 posts

The url_title() function does not work with characters with accents

Trois Riviéres -> trois-rivires

It removes the character instead of replacing “é” with “e”... the same thing happens with other characters with accents.

 
Posted: 07 October 2007 04:28 PM   [ Ignore ]   [ # 1 ]   [ Rating: 0 ]
Avatar
Joined: 2006-03-23
3194 posts

é would be illegal in a url, so that’s why its stripped out.  The problem with replacing it with “e”, is that “e” is not the same thing as “é”.  For french characters, its a pretty reasonable 1 to 1 map, but what would the url_title function do with other illegal characters, such as say… “£”?

Its tricky.  Perhaps an array of “if you see this, make it this”?  I’m not sure.  How would you suggest CI handle chars that don’t nicely map to legal URL characters?

 Signature 

DerekAllard.com - CodeIgniter, ExpressionEngine, and the World of Web Design

 
Posted: 07 October 2007 08:30 PM   [ Ignore ]   [ # 2 ]   [ Rating: 0 ]
Avatar
Joined: 2006-08-22
149 posts
yello - 07 October 2007 06:37 PM

The url_title() function does not work with characters with accents

Trois Riviéres -> trois-rivires

It removes the character instead of replacing “é” with “e”... the same thing happens with other characters with accents.

This is what i use,

function replace_accents($str{
        $str 
htmlentities($strENT_COMPAT"UTF-8");
        
$str preg_replace('/&([a-zA-Z])(uml|acute|grave|circ|tilde);/','$1',$str);
        return 
html_entity_decode($str);
    
 Signature 

Don’t argue with an idiot, people watching may not be able to tell the difference.


marcoss
http://defmay.com
http://fenix.st