Python Forum
UnicodeEncodeError: 'charmap' codec can't encode character '\u2019' in position 23: c
Thread Rating:
  • 2 Vote(s) - 3 Average
  • 1
  • 2
  • 3
  • 4
  • 5
UnicodeEncodeError: 'charmap' codec can't encode character '\u2019' in position 23: c
#1
I try to run my code in cmd command. It ran few lines of my code and gave some en code error. I posted the output below. Does anyone know why this happens? Thanks in advance.

Output:
C:\Users\resea>"C:\Users\resea\Desktop\Python Projects\ecb try 3.py" Mario Draghi, President of the ECB,Vítor Constâncio, Vice-President of the ECB,Frankfurt am Main, 10 January 2013 Get an overview of what the European Central Bank does and how it operates. More Look at press releases, speeches and interviews and filter them by date, speaker or activity. More Traceback (most recent call last): File "C:\Users\resea\Desktop\Python Projects\ecb try 3.py", line 51, in <module> print (" ".join(colored_words)) File "C:\Python34\lib\site-packages\colorama\ansitowin32.py", line 41, in write self.__convertor.write(text) File "C:\Python34\lib\site-packages\colorama\ansitowin32.py", line 162, in write self.write_and_convert(text) File "C:\Python34\lib\site-packages\colorama\ansitowin32.py", line 190, in write_and_convert self.write_plain_text(text, cursor, len(text)) File "C:\Python34\lib\site-packages\colorama\ansitowin32.py", line 195, in write_plain_text self.wrapped.write(text[start:end]) File "C:\Python34\lib\encodings\cp850.py", line 19, in encode return codecs.charmap_encode(input,self.errors,encoding_map)[0] UnicodeEncodeError: 'charmap' codec can't encode character '\u2019' in position 23: character maps to <undefined>
Reply
#2
Quote:Does anyone know why this happens?
How could we know Confused
You need to post ecb try 3.py.
Reply
#3
Obviously there is a problem with a string that the colorama module is unable to print because of en encoding issue. You could print the repr of this string, so we could look at this with colorama. Try to print the repr(" ".join(colored_words)) at line 51 in ecb try 3.py and post the result here.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  encode/decode to show correct country letters in a CTk combobox janeik 2 704 Sep-02-2023, 09:46 AM
Last Post: janeik
Question UnicodeEncodeError: 'ascii' codec can't encode character u'\xe8' in position 562: ord ctrldan 23 4,783 Apr-24-2023, 03:40 PM
Last Post: ctrldan
  UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd2 in position 16: invalid cont Melcu54 3 4,872 Mar-26-2023, 12:12 PM
Last Post: Gribouillis
  [SOLVED] [Debian] UnicodeEncodeError: 'ascii' codec Winfried 1 1,014 Nov-16-2022, 11:41 AM
Last Post: Winfried
  UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position 34: character Melcu54 7 18,756 Sep-26-2022, 10:09 AM
Last Post: Melcu54
  UnicodeEncodeError - Dealing with Japanese Characters fioranosnake 2 2,432 Jul-07-2022, 08:43 PM
Last Post: fioranosnake
  UnicodeEncodeError: 'ascii' codec can't encode character '\xfd' in position 14: ordin Armandito 6 2,703 Apr-29-2022, 12:36 PM
Last Post: Armandito
  UnicodeEncodeError caused by print when program runs from Popen SheeppOSU 5 2,898 Jan-13-2022, 08:11 AM
Last Post: SheeppOSU
  [UnicodeEncodeError from smtplib] yoohooos 0 3,372 Sep-25-2021, 04:27 AM
Last Post: yoohooos
  ASCII-Codec in Python3 [SOLVED] AlphaInc 4 6,092 Jul-07-2021, 07:05 PM
Last Post: AlphaInc

Forum Jump:

User Panel Messages

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