[reportlab-users] Problems with unicode in labels of pie charts
Sebastian Ware
sebastian at urbantalk.se
Fri Sep 28 07:27:39 EDT 2007
Very interesting!
In a UTF-8 encoded source code file I create the following list of
labels:
[u'ett', u'två', u'tré', '\xc3\xa5\xc3\xa4\xc3\xb6']
Where the first and last label prints as expected, but the middle two
won't. I guess the work around is to convert the labels to strings
and manually replace the non-ascii characters with their unicode
encoding, but that doesn't feel too good...
Mvh Sebastian
28 sep 2007 kl. 13.14 skrev Robin Becker:
> Sebastian Ware wrote:
>> Hi!
>> I am new to Reportlab and it is very impressive. I have however
>> come across a problem with unicode in pie charts.
>> Labels with non-ascii charcters print fine in a bar chart, but not
>> in a pie chart. Reportlab simply refuses to print the label
>> containing these non-ascii characters (Swedish åäö or french é).
>> Any ideas on how to solve this problem?
>> Mvh Sebastian
> ......
>
> Are you encoding the labels in utf-8? To test try setting one of
> the labels to
>
> '\xc3\xa5\xc3\xa4\xc3\xb6' which seems to give the right output.
>
> If you wish to type in latin1 and pass to the label the correct
> function is
>
> def latin1_to_utf8(s):
> return s.decode('latin1').encode('utf-8')
> --
> Robin Becker
> _______________________________________________
> reportlab-users mailing list
> reportlab-users at reportlab.com
> http://two.pairlist.net/mailman/listinfo/reportlab-users
More information about the reportlab-users
mailing list