Japanese charaters in code igniter urls

Bookmark and Share

Code igniter is restrictive over permitted url characters (a good thing!), and it’s simple enough to edit the permitted_uri_config option to add more charaters. However, what if you’re dealing with Japanese charaters in the url?

Well (after a little searching) it turns out that this isn’t too difficult to fix as the config value is a regex and one can add the kanji charater ranges in a similar fashion to the standard ascii ‘a-z’ syntax:


$config['permitted_uri_chars'] = ‘a-z 0-9~%.:_-’;
        ↓
$config['permitted_uri_chars'] = ‘一-龠ぁ-んァ-ヴーa-zA-Z0-9a-z 0-9~%.:_-’;

courtesy of: http://pricewave.blog110.fc2.com/blog-category-4.html

3 Responses to “Japanese charaters in code igniter urls”


  1. 1 autoreverse Dec 11th, 2007 at 3:29 pm

    Hi Chris

    Here’s the other solution (hack) I promised (I should learn to scroll below the fold)

    In Router.php change

    if ( ! preg_match(”|^[".preg_quote($this->config->item('permitted_uri_chars'))."] $|i”, $str))

    to

    if ( ! preg_match(”|^[".preg_quote($this->config->item('permitted_uri_chars'))."] $|i”, rawurlencode($str)))

    A link to the bug report: http://www.codeigniter.com/bug_tracker/bug/2929/

    Derek Allard says the CI guys are working on a better solution but you might want to add yours too so they are aware of what other people are doing.

  2. 2 yongfook Mar 1st, 2008 at 9:54 am

    dude, I freaking looked everywhere for this regex expression for one of my old projects. my google skills are the fail. thanks for posting the solution!

  1. 1 Code Igniter Japanese Localisation Pingback on Jan 23rd, 2008 at 4:44 am

Leave a Reply




About MrKirkland

more...

Tweets

Posting tweet...

Timezone

  • JST: 2010-03-11 08:58
  • GMT: 2010-03-10 23:58
  • PST: 2010-03-10 15:58
  • EDT: 2010-03-10 19:58