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).