Proposal (see issue 626):

Try:

>>> s = 'äöü€'
>>> for i in range(10):
...  print s[:i]+'...'
...
...
�...
ä...
ä�...
äö...
äö�...
äöü...
äöü�...
äöü��...
äöü€...
>>> for i in range(10):
...  print s*.decode('utf-8')*[:i]*.encode('utf-8')*+'...'...
...
ä...
äö...
äöü...
äöü€...
äöü€...
äöü€...
äöü€...
äöü€...
äöü€...


In an SQLFORM.grid strings, which are too long, will be cropped. But
multi-byte characters should not be split.

Proposal: gluon/sqlhtml.py, line 1800
Change:

elif isinstance(value,str) and len(value)>maxtextlength:
   value=value[:maxtextlengths.get(str(field),maxtextlength)]+'...'


to:

elif isinstance(value,str) and len(value)>maxtextlength:
   value=value*.decode('utf-8')*\
     [:maxtextlengths.get(str(field),maxtextlength)]\
     *.encode('utf-8')*+'...'


Maybe there is a better solution, but it works.

2012/1/12 Martin Weissenboeck <[email protected]>

> Let's say I have made a SQLFORM.grid.
>
> There is a cell containing "--------------ÄÖÜ" and everything looks fine:
>
> --------------ÄÖÜ
>
> If I add one hyphen the string will be too long. But it is not the whole
> character 'Ü' which will be cropped, it's only the second byte. The utf-8
> coding of 'Ü' is 0xC39C and the grid tries to display ÄÖ and 0xC3:
>
> ---------------ÄÖ�...
>
> Any solutions?
>  Martin
>

Reply via email to