This worked:

ur=unicode(r,'utf8')
if len(ur)>truncate: r=ur[:truncate-3].encode('utf8') + '...'

Thank you!

On Nov 26, 6:18 pm, mdipierro <[EMAIL PROTECTED]> wrote:
> It is a bug in the sense that the utf8 is truncated while it should be
> converted to unicode, then truncated.
> This line in gluon/sqlhtml.py needs to be fixed:
>
>                 if len(r)>truncate: r=r[:truncate-3]+'...'
>
> perhaps replace by
>
>                 ur=unicode(r,'utf8)
>                 if len(ur)>truncate: r=ur[:truncate-3].encode('utf8')
> +'...'
>
> Could you give it a try?
>
> Anyway you can change the truncate variable. In  your code:
>
>     table=SQLTABLE(db().select(db.data_storage.ALL, limitby=
> (0,20)),truncate=100,
> _class='flexit', _width='100%')
>
> On Nov 26, 9:07 am, SergeyPo <[EMAIL PROTECTED]> wrote:
>
> > Here is a screenshot:http://zarealye.com/snapshot.jpg
> > Here I try to use flexigrid but the same happens with web2py db
> > administration page.
> > You will see black diamonds with questionmark...
> > These are Russian strings (UTF-8) truncated. Is it possible to
> > increase the length? Is there not a bug in utf-8 truncation?
> > I guess, simply   u"long russian text"[:10] won't work correctly in
> > utf.
>
> > On Nov 26, 5:22 pm, mdipierro <[EMAIL PROTECTED]> wrote:
>
> > > Can you show us a screen shot to make sure I understand?
>
> > > It is true that SQLTABLE (on purpose) truncates strings to a fix
> > > number of characters. Perhaps this is your problem.
>
> > > If you need a table that displays long string you should make your own
> > > table
>
> > > <table>
> > >   {{ for row in db().select(db.data_storage.ALL, limitby=(0,20)): }}
> > >   <tr>
> > >     {{ for field in db.data_storage_fields:}}
> > >       <td>{{=row[field]}}</td>
> > >     {{pass}}
> > >   </tr>
> > >   {{pass}}
> > > </table>
>
> > > On Nov 26, 8:13 am, SergeyPo <[EMAIL PROTECTED]> wrote:
>
> > > > Hello Group!
>
> > > > When I do in controller:
>
> > > >     table=SQLTABLE(db().select(db.data_storage.ALL, limitby=(0,20)),
> > > > _class='flexit', _width='100%')
> > > >     return dict(table = table)
>
> > > > strings that are in database (utf-8 coded) are displayed truncated :
> > > > part of the string, than question mark in diamond symbol, than eclipse
> > > > (...)
>
> > > > Афанас ...
> > > > Балмак ...
>
> > > > etc.
>
> > > > This happens both in my code and in db administration page.
> > > > When I do:
>
> > > >     print db().select(db.data_storage.ALL, limitby=(0,20))
>
> > > > I get correct strings in Terminal, so data in database is correct.
>
> > > > How to fix that?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to