Wrong result of strlen() with UTF-8 characters generates a validation error
MDD - September 10, 2007 - 19:58
| Project: | Content Construction Kit (CCK) |
| Version: | 5.x-1.6-1 |
| Component: | text.module |
| Category: | bug report |
| Priority: | critical |
| Assigned: | Unassigned |
| Status: | patch (code needs review) |
Description
The designated maximum length text fields do not correspond to the actual, in the Russian charsets (UTF-8-general-ci).
It is less than three times. A English encoding no problems :(
Example: If I set a length field of 30 characters, it can enter only 10 (Russians charsets) or 30 English charsets.
After submitting forms error message exceeding the limit, which does not meet reality.
Thank you for your attention.

#1
Solution.
In function text_field() (file text.module) replace line
if (strlen($data['value']) > $field['max_length']) {with
if (mb_strlen($data['value'],"UTF-8") > $field['max_length']) {That seems to work.
#2
Hello.
Using drupal_strlen() seems to be a better solution
#3
The Russians are still not coming? Ok, here's a patch.