Are non-english characters 100% supported in codei

2020-07-28 02:37发布

问题:

I want to be sure if this behavior is 100% supported in CodeIgniter.

What doubts me is that in config.php the permitted_uri_chars is as followed:

$config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-';

It says that only English chars are allowed. BUT consider the results of following urls:

  • http://localhost/codeigniter/index.php/controller/method/hell0-there+++

Result: The URI you submitted has disallowed characters.

  • http://localhost/codeigniter/index.php/controller/method/hello-سلام

Result: No problem!!!

The word سلام (which is in Persian and means "hello") cannot be accepted by the pattern 'a-z 0-9~%.:_\-', but it doesn't error like the previous example!

Why does this behavior happen?

Now the next question: Is there any NEED to add and include Persian characters in the pattern?

I was thinking of changing the config.php to be like this:

$config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-';

// Add all the persian characters after standard pattern:
$config['permitted_uri_chars'] .= 'آابپتثجچحخدذرزسشصضطظعغفقکگلمنوهیي‌۱۲۳۴۵۶۷۸۹۰';

回答1:

Non-ASCII character should be URLEncoded converting them to %F3 etc. Which I believe would be allowed based on the % and a-z 0-9



回答2:

Use it in this way, Change the Config File:

$config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-|آ-ی';

In This way it supports all charachters except "Hamze". And if you want to Support "Hamze" you can change it in this way :

$config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-|آ-یء';


回答3:

I have just read your question and it has a simple answer that i have reached! The answer is :

$route[urlencode ('ورود-به-حساب-کاربری')] = 'Login';

You do not need to manipulate your config file as you told! So you only need to set this line of code into your route.php as well. It works for me.