Welcome Guest, Not a member yet? Register   Sign In
Is there a standard way to handle diacritics in URLs for CI?
#2

[eluser]j√°quer[/eluser]
Maybe use something like this? Add this to an "unaccent" helper:

Code:
function unaccent($text) {
  static $search, $replace;
  if (!$search) {
    $search = $replace = array();
    // Get the HTML entities table into an array
    $trans = get_html_translation_table(HTML_ENTITIES);
    // Go through the entity mappings one-by-one
    foreach ($trans as $literal => $entity) {
      // Make sure we don't process any other characters
      // such as fractions, quotes etc:
      if (ord($literal) >= 192) {
        // Get the accented form of the letter
        $search[] = utf8_encode($literal);
        // Get e.g. 'E' from the string 'É'
        $replace[] = $entity[1];
      }
    }
  }
  return str_replace($search, $replace, $text);
}

And then:

Code:
$this->load->helper('url');
$this->load->helper('unaccent');

$title = unaccent($title);
$title = url_title($title, 'dash', TRUE);

Code for the unaccent function found a hasty Google search, which lead me here. There might be better implementations of it.


Messages In This Thread
Is there a standard way to handle diacritics in URLs for CI? - by El Forum - 03-12-2010, 04:43 PM



Theme © iAndrew 2016 - Forum software by © MyBB