Are non-english characters 100% supported in codeigniter urls by default?

血红的双手。 提交于 2019-12-06 09:23:33

问题


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.



来源:https://stackoverflow.com/questions/9368668/are-non-english-characters-100-supported-in-codeigniter-urls-by-default

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!