4

Is it possible to make url_title() produce rephrasing of this strings:

čolić
nešto

Into:

colic
nesto

I believe that this could be useful with Latin-base UTF8 languages and setting up more pretty and descriptive URLs for non-Latin languages.

Dexy_Wolf
  • 989
  • 3
  • 13
  • 25
  • Just to be clear, this has little to do with UTF-8. You just want to convert latin characters with diacritics into similar latin characters without diacritics. – deceze Dec 11 '11 at 23:55
  • For example like this: [How to remove diacritics from text?](http://stackoverflow.com/questions/1770250/how-to-remove-diacritics-from-text) – deceze Dec 11 '11 at 23:57
  • It should be that. Is it possible to alter `url_title()` to do that automatically, without writing additional function? – Dexy_Wolf Dec 12 '11 at 00:03
  • I am new to CodeIgniter world, so I forgot that I could extend helpers. Thank you for the comment. – Dexy_Wolf Dec 12 '11 at 00:19

2 Answers2

13

Just tie into the convert_accented_characters function:

url_title(convert_accented_characters('čolić'));
Eric
  • 1,197
  • 9
  • 18
1

I'm using

$this->load->helper('text');
$string = 'tèst Tést ççÇçandãÃ';
$title = url_title(convert_accented_characters(utf8_encode(strtolower($string)));
// return: test-test-cccandaa
Umair Khan
  • 1,684
  • 18
  • 34