Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
fpdf star character issue
#1
Hello,

I have a database with a number of fields and 1 of the fields is Rating. This field contains the word, One, Two, Three, Four or Five.

Each time I loop through a record, I want the Rating string to be converted to x number of stars based on the string passed to it.

I have written a function that does this. The function displays the correct # of stars if I am sending the output to my VSC Terminal. When I try convertting it to a pdf (using fpdf) I receive an error:

# partial code in my fpdf function
tmp = star_rating(row[7])
pdf.cell(25, 0, tmp, align="L", border=0)

# partial code in star_rating()
star = "\u2B50"
if string == "Three":
        times = 3
etc.
return star * times
UnicodeEncodeError: 'latin-1' codec can't encode characters in position 1275-1278: ordinal not in range(256)
The font I am using is Arial.
Reply


Messages In This Thread
fpdf star character issue - by KatMac - May-01-2021, 04:32 PM
RE: fpdf star character issue - by ibreeden - May-01-2021, 05:51 PM
RE: fpdf star character issue - by bowlofred - May-01-2021, 05:52 PM
RE: fpdf star character issue - by KatMac - May-01-2021, 06:22 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Turtle Star Fill Color Yellow-White Interchanging Color Effect codelab 9 990 Oct-25-2023, 09:09 AM
Last Post: codelab
  Label Maker FPDF, Reportlab jamesaarr 1 2,657 Aug-09-2021, 11:57 PM
Last Post: Pedroski55
  [solved] unexpected character after line continuation character paul18fr 4 3,393 Jun-22-2021, 03:22 PM
Last Post: deanhystad
  fpdf orientation not working properly KatMac 1 3,321 May-02-2021, 10:47 AM
Last Post: Pedroski55
  fpdf adding a new font to my report KatMac 0 2,163 Apr-23-2021, 02:19 PM
Last Post: KatMac
  ModuleNotFoundError: No module named 'fpdf' KatMac 4 11,164 Apr-19-2021, 01:23 PM
Last Post: KatMac
  How to scrape and count star rating using Selenium and Python? celinafregoso99 1 3,302 Feb-15-2021, 02:45 PM
Last Post: kashcode
  FPDF question DPaul 2 2,767 Oct-27-2020, 08:26 AM
Last Post: DPaul
  SyntaxError: unexpected character after line continuation character siteshkumar 2 3,166 Jul-13-2020, 07:05 PM
Last Post: snippsat
  Why there is a star inside randn? new_to_python 4 2,502 Mar-06-2020, 04:45 AM
Last Post: new_to_python

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020