alfonsodg / demo-web2py

Apache License 2.0
0 stars 0 forks source link

we say strings are utf8, but don't count their length as such #34

Closed alfonsodg closed 10 years ago

alfonsodg commented 10 years ago

From attila.c...@gmail.com on March 26, 2009 07:19:58

In [1]: validator = IS_LENGTH(1)

In [2]: validator('a') Out[2]: ('a', None)

In [3]: validator('aa') Out[3]: ('aa', 'too long!')

In [4]: validator('á') Out[4]: ('\xc3\xa1', 'too long!')

In [5]: validator('á'.decode('utf-8')) Out[5]: (u'\xe1', None)

In [6]: validator('ж'.decode('utf-8')) Out[6]: (u'\u0436', None)

Original issue: http://code.google.com/p/web2py/issues/detail?id=35

alfonsodg commented 10 years ago

From massimod...@gmail.com on April 27, 2009 21:24:30

we do not have a choice. Some database backends do not understand unicode so we encode as UTF thus the length we validate against is not the actual number of unicode characters but the number of UTF8 characters.

Status: WontFix