112madgamer
112madgamer

Reputation: 195

Python Curses UI printing Unicode

Hello I am making a simple Curses UI app I have everything working. I am trying to print this █ in my progress bar but when I do i get this error

File "simple.py", line 100, in <module>                                                                       │
│           main()                                                             │
│           File "simple.py", line 55, in main                         │
│           show_progress()      │
│           File "simple.py", line 83, in show_progress                                         │
│           win.addstr(1,pos,u"\u2588")          │
│UnicodeEncodeError: 'ascii' codec can't encode character u'\u2588' in position 0: ordinal not in range(128)     

I Know this is a horrible error but it is how it is printed out

Here is the code that is printing it

win.addstr(1,pos,u"\u2588")

Upvotes: 0

Views: 427

Answers (1)

Tim Seed
Tim Seed

Reputation: 5279

Python 2 does not understand Unicode - it only understands bytes...

So port to Python3 (Easy unless you are doing Network programming) or start doing

bytes(unicode_string.encode('utf-8'))

Everywhere in your code.

Upvotes: 1

Related Questions