[SOLUTION FOUND]Validation library has incorrect length rules for non-latin utf8 characters - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: [SOLUTION FOUND]Validation library has incorrect length rules for non-latin utf8 characters (/showthread.php?tid=7175) |
[SOLUTION FOUND]Validation library has incorrect length rules for non-latin utf8 characters - El Forum - 03-28-2008 [eluser]Skuja[/eluser] Validation library length rules returns invalid length for non-latin utf8 characters. For example if i set rule max_length[2] for a field and try to validate data: "šķ" it returns invalid length error. Does anybody has good workaround for this, or should i add callback function each time on validation? EDITED: I replaced native Validation library with my modified version, where i replaced Code: strlen($str) Code: mb_strlen($str,'utf8') PS. I have read that mb_strlen function is slow. Maybe anyone has found better solution? [SOLUTION FOUND]Validation library has incorrect length rules for non-latin utf8 characters - El Forum - 03-28-2008 [eluser]xwero[/eluser] Wait for php6 but that is not a solution I believe there are some php hacks to use unicode strings. [SOLUTION FOUND]Validation library has incorrect length rules for non-latin utf8 characters - El Forum - 12-14-2008 [eluser]alex-and-r[/eluser] [quote author="xwero" date="1206715268"]Wait for php6 but that is not a solution I believe there are some php hacks to use unicode strings.[/quote] Why isn't it a solution? Can you explain a bit further? Cuz I have the same problem with russian characters! [SOLUTION FOUND]Validation library has incorrect length rules for non-latin utf8 characters - El Forum - 12-15-2008 [eluser]Skuja[/eluser] It is a solution, therefore in version 1.7 this problem has been fixed. [SOLUTION FOUND]Validation library has incorrect length rules for non-latin utf8 characters - El Forum - 12-15-2008 [eluser]alex-and-r[/eluser] [quote author="Skuja" date="1229353660"]It is a solution, therefore in version 1.7 this problem has been fixed.[/quote] It's strange but I'm using version 1.7 of CI and I get this very problem. May be it's because of the encoding - I'm not using UTF8? [SOLUTION FOUND]Validation library has incorrect length rules for non-latin utf8 characters - El Forum - 12-15-2008 [eluser]Skuja[/eluser] form_validation uses mb_strlen function only if it available, otherwise standard strlen is used: Code: if (function_exists('mb_strlen')) this line should be un uncomented: Code: extension=php_mbstring.dll |