Jefim Borissov The mighty web developer!

11Dec/092

CodeIgniter – Cart crap with Cyrillic characters

Ok, now this is so ridiculous that I have to blog about this even though I do not want to. CodeIgniter just blew my mind some time ago when I upgraded to 1.7.2 for the new Cart library. I realize, that it is a basic functionality, yet still... It does not support cyrillic characters in the product name! It is freaking 2009, almost 2010 and one of the most popular MVC frameworks does not support cyrillic? And I bet any other "strange" characters too, because basically they have a filter there with a regexp:

var $product_name_rules	= '\.\:\-_ a-z0-9';

Now that is some serious shit! :)

Anyway, if you have trouble with the same thing - doing non-latin chars in product names just find and comment out the following part from system/libraries/Cart.php:

if ( ! preg_match("/^[".$this->product_name_rules."]+$/i", $items['name']))
{
	log_message('error', 'An invalid name was submitted as the product name: '.$items['name'].' The name can only contain alpha-numeric characters, dashes, underscores, colons, and spaces');
	return FALSE;
}

Also, if you are using a database table for your sessions - do not forget to check that the user_data field uses UTF-8 as its encoding (otherwise it won't let cyr chars into the field).

This website uses IntenseDebate comments, but they are not currently loaded because either your browser doesn't support JavaScript, or they didn't load fast enough.

Comments (2) Trackbacks (0)
  1. Thx for your post…

    I had the same problem.

    You are right, if everything is UTF8 I don't see why is there a need to limit product names to English only??!!

  2. Greetings,
    If you use UTF8, you can simple place /u at the end like this: preg_match("/^[".$this->product_name_rules."]+$/iu
    and replace var $product_name_rule to var $product_name_rules = '.:-_ a-z0-9а-я';


Leave a comment


No trackbacks yet.