0

I am reading a first and last name in Python from a file and am having trouble with encoding. I want to print out the name, but am getting "UnicodeEncodeError: 'charmap' codec can't encode character '\u021b' in position 11: character maps to undefined" with this code:

 first = obj.first_name.encode('utf-8')
 last = obj.last_name.encode('utf-8')
 first = first.decode('utf-8')
 last = last.decode('utf-8')
 print(first)

What is the problem?

asked Aug 7, 2011 at 1:23
0

1 Answer 1

2

The problem is that your output terminal/console doesn't have any way of displaying ț. Try chcp 65001 before running the script if you're using Windows.

answered Aug 7, 2011 at 1:25
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.