Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Does Phalcon\Mvc\Model\Validator\StringLength check multibyte length?

I'm wondering if Phalcon\Mvc\Model\Validator\StringLength checks for multibyte length using something like the mb_strlen function for the international market. If not then perhaps there should be an option for enabling that.

In my case I'm setting the database varchar field higher than the number of actual symbols that I want to allow. Then that validation is done with Phalcon.



5.0k
Accepted
answer
edited Feb '15

Well if you are using Phalcon 2 and you have installed mb extension the answer is yes https://github.com/phalcon/cphalcon/blob/2.0.0/phalcon/validation/validator/stringlength.zep#L79



44.7k

That is cool in a way but its also kind of scary that it can be inconsistent like that. I think that the behaviour should only change like that based upon an option and then to throw an exception if it can't do what it is trying to do.



44.7k

One of these days I'll just start reading Zephir source code when I have a question.