[reportlab-users] Unicode problem in para.py

Michael Egorov michwill at gmail.com
Wed Sep 9 08:37:24 EDT 2009


yeah, that's good) Thank you

I used para.py just because it supports ul/li lists. They work really not
ideally: especially if every li is really long (several strings). I will
discuss that later

2009/9/9 Robin Becker <robin at reportlab.com>


> Michael Egorov wrote:

>

>> I have unicode problem in para.py here:

>>

>> elif standard.has_key(name):

>> fragment = standard[name]+fragment[semi+1:]

>> elif greeks.has_key(name):

>> fragment = greeks[name]+fragment[semi+1:] # just here

>> (line 2041)

>>

>> It happens because greeks[name] is a string whether fragment is unicode.

>> String cannot be converted to unicode if you don't know the encoding.

>> To reproduce that you need any character from greeks in text for Para

>>

>> The patch wich makes it working:

>>

>> --- platypus/para.py (revision 3542)

>> +++ platypus/para.py (working copy)

>> @@ -2038,7 +2038,7 @@

>> elif standard.has_key(name):

>> fragment = standard[name]+fragment[semi+1:]

>> elif greeks.has_key(name):

>> - fragment = greeks[name]+fragment[semi+1:]

>> + fragment = unicode(greeks[name],

>> "utf-8")+fragment[semi+1:]

>> else:

>> # add back the &

>> fragment = "&"+fragment

>>

>> Is it possible to commit that to the main repository somehow?

>> How to get a developer access to the reportlab svn?

>>

> .......

>

> Logically we have two cases, when fragment is unicode or when fragment is

> str. We ought to do all of these additions more carefully in the unicode/str

> world. Does this work for you?

>

> --- para.py (revision 3542)

> +++ para.py (working copy)

> @@ -2036,9 +2036,15 @@

> else:

> fragment = "&"+fragment

> elif standard.has_key(name):

> - fragment = standard[name]+fragment[semi+1:]

> + s = standard[name]

> + if isinstance(fragment,unicode):

> + s = s.decode('utf8')

> + fragment = s+fragment[semi+1:]

> elif greeks.has_key(name):

> - fragment = greeks[name]+fragment[semi+1:]

> + s = greeks[name]

> + if isinstance(fragment,unicode):

> + s = s.decode('utf8')

> + fragment = s+fragment[semi+1:]

> else:

> # add back the &

> fragment = "&"+fragment

>

> I'm not a great user of para.py and it probably doesn't get much attention.

> --

> Robin Becker

> _______________________________________________

> reportlab-users mailing list

> reportlab-users at reportlab.com

> http://two.pairlist.net/mailman/listinfo/reportlab-users

>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://two.pairlist.net/pipermail/reportlab-users/attachments/20090909/03bd44a2/attachment.html>


More information about the reportlab-users mailing list