开发者

CodeIgniter - Does 'name' regex match in Cart class support Unicode?

开发者 https://www.devze.com 2023-01-28 05:21 出处:网络
I want to include unicode characters (to be more specific, Tamil words) in the \'name\' of my Code Igniter cart.I found this example.I tried the following, so that the regex could match anything:

I want to include unicode characters (to be more specific, Tamil words) in the 'name' of my Code Igniter cart. I found this example. I tried the following, so that the regex could match anything:

$this->cart->product_name_rules = '.+';
$this->cart->product_name_rules = '.开发者_StackOverflow*';
$this->cart->product_name_rules = '.';

But for all these, I get the error "An invalid name was submitted as the product name: சும்மாவா சொன்னாங்க பெரியவங்க The name can only contain alpha-numeric characters, dashes, underscores, colons, and spaces" in my log.

Also, thinking it could be due to unicode support, I tried the following:

$this->cart->product_name_rules = '\p{Tamil}';

But to no avail. Can you please point if something wrong here?


Try adding each Tamil character individually to your regex. I had to do this for special characters in input keys:

    if ( ! preg_match("/^[a-z0-9àÀâÂäÄáÁãÃéÉèÈêÊëËìÌîÎïÏòÒôÔöÖõÕùÙûÛüÜçÇ’ñÑß¡¿œŒæÆåÅøØö:_\.\-\/-\\\,]+$/i", $str))
    {
        exit('Disallowed Key Characters.');
    }


Here he posted how did he managed to save the cyrilic character in Codeigniter 1.7.2's cart.

0

精彩评论

暂无评论...
验证码 换一张
取 消