[reportlab-users] utf-8 characters

Amit Mongia reportlab-users@reportlab.com
Sun, 2 May 2004 22:35:39 -0700 (PDT)


Sorry friend,
No idea about this.
Regards,
Amit Mongia
--- David Bourillot <David.Bourillot@cern.ch> wrote:
> Re: [reportlab-users] utf-8 charactersHello,
> 
> Thanks for your help. I use the Times New Roman font
> and it's work fine for
> most of the documents.
> But I have a problem with one where there is this
> string: "UNIVERSIT?DI
> NAPOLI"
> The string is encoded with utf-8 and when I generate
> the PDF, I get this
> error:
> 
> File
>
"c:/MaKaC/indico/code/code\MaKaC\webinterface\rh\base.py",
> line 204, in
> process
>     res = self._process()
> 
>   File
>
"c:/MaKaC/indico/code/code\MaKaC\webinterface\rh\abstractModif.py",
> line 88, in _process
>     data = pdf.getPDFBin()
> 
>   File
>
"c:/MaKaC/indico/code/code\MaKaC\PDFinterface\base.py",
> line 137, in
> getPDFBin
>     self._doc.build(self._story,
> onFirstPage=self.firstPage,
> onLaterPages=self.laterPages)
> 
>   File
>
"C:\Python23\lib\site-packages\reportlab\platypus\doctemplate.py",
> line 801, in build
>     BaseDocTemplate.build(self,flowables)
> 
>   File
>
"C:\Python23\lib\site-packages\reportlab\platypus\doctemplate.py",
> line 631, in build
>     self.handle_flowable(flowables)
> 
>   File
>
"C:\Python23\lib\site-packages\reportlab\platypus\doctemplate.py",
> line 549, in handle_flowable
>     if self.frame.add(f, self.canv,
> trySplit=self.allowSplitting):
> 
>   File
>
"C:\Python23\lib\site-packages\reportlab\platypus\frames.py",
> line
> 120, in _add
>     w, h = flowable.wrap(self._getAvailableWidth(),
> h)
> 
>   File
>
"C:\Python23\lib\site-packages\reportlab\platypus\paragraph.py",
> line
> 421, in wrap
>     self.blPara = self.breakLines([first_line_width,
> later_widths])
> 
>   File
>
"C:\Python23\lib\site-packages\reportlab\platypus\paragraph.py",
> line
> 564, in breakLines
>     for w in _getFragWords(frags):
> 
>   File
>
"C:\Python23\lib\site-packages\reportlab\platypus\paragraph.py",
> line
> 199, in _getFragWords
>     n = n + stringWidth(w, f.fontName, f.fontSize)
> 
>   File
>
"C:\Python23\lib\site-packages\reportlab\pdfbase\pdfmetrics.py",
> line
> 632, in _slowStringWidth
>     return font.stringWidth(text, fontSize)
> 
>   File
>
"C:\Python23\lib\site-packages\reportlab\pdfbase\ttfonts.py",
> line
> 987, in stringWidth
>     for code in parse_utf8(text):
> 
>   File
>
"C:\Python23\lib\site-packages\reportlab\pdfbase\ttfonts.py",
> line
> 82, in
>     parse_utf8=lambda x,
> decode=codecs.lookup('utf8')[1]:
> map(ord,decode(x)[0])
> 
> Exception type: exceptions.UnicodeDecodeError
> Exception message: 'utf8' codec can't decode byte
> 0xc3 in position 9:
> unexpected end of data
> 
> 
> After some little investigation, it's seems to me
> that when the string is
> split, it's cut between the two bytes of the encoded
> character '?#39;
> 
> Am I right? is it a known bug?
> 
> Best regards,
> David
>   -----Original Message-----
>   From: reportlab-users-admin@reportlab.com
> [mailto:reportlab-users-admin@reportlab.com]On
> Behalf Of Amit Mongia
>   Sent: jeudi 29 avril 2004 11:58
>   To: reportlab-users@reportlab.com
>   Subject: Re: [reportlab-users] utf-8 characters
> 
> 
>   Hi,
>   Create a ttf font object and render it using that.
> Go
>   through the example that comes with the user guide
> for
>   rina.ttf.
>   You can use the popular windows font Times New
> Roman
>   instead. Or some other ttf font of your choice.
>   Happens using font embedding.
>   Regards,
>   Amit Mongia
>   --- David Bourillot <David.Bourillot@cern.ch>
> wrote:
>   > Hello,
>   >
>   > I use reportlab to generate documents and my
> problem
>   > is some special
>   > characters are not displayed correctly.
>   > I use string encoded in utf-8.
>   > How can I do to get theses characters well
>   > displayed?
>   >
>   > Thanks in advance,
>   > David
>   >
>   > _______________________________________________
>   > reportlab-users mailing list
>   > reportlab-users@reportlab.com
>   >
>  
>
http://two.pairlist.net/mailman/listinfo/reportlab-users
> 
> 
> 
> 
> 
> 
>   __________________________________
>   Do you Yahoo!?
>   Win a $20,000 Career Makeover at Yahoo! HotJobs
>  
> http://hotjobs.sweepstakes.yahoo.com/careermakeover
>   _______________________________________________
>   reportlab-users mailing list
>   reportlab-users@reportlab.com
>  
>
http://two.pairlist.net/mailman/listinfo/reportlab-users
> 



	
		
__________________________________
Do you Yahoo!?
Win a $20,000 Career Makeover at Yahoo! HotJobs  
http://hotjobs.sweepstakes.yahoo.com/careermakeover