Skip to main content
edit for appropriate timelessness and to remove forum-mode discussion
Source Link
Karl Knechtel
  • 61.4k
  • 14
  • 131
  • 193

When I try to printprint a Unicode string in a Windows console, sometimes I get an error that says .

UnicodeEncodeError: 'charmap' codec can't encode character ....

 . I assume this is because the Windows console does not acceptcannot handle all Unicode-only characters. What's the best way

How can I work around this? Is there any way I For example, how can I make Python automatically printthe program display a replacement character (such as ?) instead of failing in this situation?

Edit: I'm using Python 2.5.


Note: @LasseV.Karlsen answer with the checkmark is sort of outdated (from 2008). Please use the solutions/answers/suggestions below with care!!

@JFSebastian answer is more relevant as of today (6 Jan 2016).

When I try to print a Unicode string in a Windows console, I get an error .

UnicodeEncodeError: 'charmap' codec can't encode character ....

  I assume this is because the Windows console does not accept Unicode-only characters. What's the best way around this? Is there any way I can make Python automatically print a ? instead of failing in this situation?

Edit: I'm using Python 2.5.


Note: @LasseV.Karlsen answer with the checkmark is sort of outdated (from 2008). Please use the solutions/answers/suggestions below with care!!

@JFSebastian answer is more relevant as of today (6 Jan 2016).

When I try to print a string in a Windows console, sometimes I get an error that says UnicodeEncodeError: 'charmap' codec can't encode character ..... I assume this is because the Windows console cannot handle all Unicode characters.

How can I work around this? For example, how can I make the program display a replacement character (such as ?) instead of failing?

When I try to print a Unicode string in a Windows console, I get aan error .

UnicodeEncodeError: 'charmap' codec can't encode character .... error. I

I assume this is because the Windows console does not accept Unicode-only characters. What's the best way around this? Is Is there any way I can make Python automatically print a ? instead of failing in this situation?

Edit: I'm using Python 2.5.


Note: @LasseV.Karlsen answer with the checkmark is sort of outdated (from 2008). Please use the solutions/answers/suggestions below with care!!

@JFSebastian answer is more relevant as of today (6 Jan 2016).

When I try to print a Unicode string in a Windows console, I get a UnicodeEncodeError: 'charmap' codec can't encode character .... error. I assume this is because the Windows console does not accept Unicode-only characters. What's the best way around this? Is there any way I can make Python automatically print a ? instead of failing in this situation?

Edit: I'm using Python 2.5.


Note: @LasseV.Karlsen answer with the checkmark is sort of outdated (from 2008). Please use the solutions/answers/suggestions below with care!!

@JFSebastian answer is more relevant as of today (6 Jan 2016).

When I try to print a Unicode string in a Windows console, I get an error .

UnicodeEncodeError: 'charmap' codec can't encode character ....

I assume this is because the Windows console does not accept Unicode-only characters. What's the best way around this? Is there any way I can make Python automatically print a ? instead of failing in this situation?

Edit: I'm using Python 2.5.


Note: @LasseV.Karlsen answer with the checkmark is sort of outdated (from 2008). Please use the solutions/answers/suggestions below with care!!

@JFSebastian answer is more relevant as of today (6 Jan 2016).

replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link
URL Rewriter Bot
URL Rewriter Bot

When I try to print a Unicode string in a Windows console, I get a UnicodeEncodeError: 'charmap' codec can't encode character .... error. I assume this is because the Windows console does not accept Unicode-only characters. What's the best way around this? Is there any way I can make Python automatically print a ? instead of failing in this situation?

Edit: I'm using Python 2.5.


Note: @LasseV.Karlsen answer with the checkmark is sort of outdated (from 2008). Please use the solutions/answers/suggestions below with care!!

@JFSebastian answer@JFSebastian answer is more relevant as of today (6 Jan 2016).

When I try to print a Unicode string in a Windows console, I get a UnicodeEncodeError: 'charmap' codec can't encode character .... error. I assume this is because the Windows console does not accept Unicode-only characters. What's the best way around this? Is there any way I can make Python automatically print a ? instead of failing in this situation?

Edit: I'm using Python 2.5.


Note: @LasseV.Karlsen answer with the checkmark is sort of outdated (from 2008). Please use the solutions/answers/suggestions below with care!!

@JFSebastian answer is more relevant as of today (6 Jan 2016).

When I try to print a Unicode string in a Windows console, I get a UnicodeEncodeError: 'charmap' codec can't encode character .... error. I assume this is because the Windows console does not accept Unicode-only characters. What's the best way around this? Is there any way I can make Python automatically print a ? instead of failing in this situation?

Edit: I'm using Python 2.5.


Note: @LasseV.Karlsen answer with the checkmark is sort of outdated (from 2008). Please use the solutions/answers/suggestions below with care!!

@JFSebastian answer is more relevant as of today (6 Jan 2016).

added 152 characters in body
Source Link
alvas
  • 123.4k
  • 118
  • 503
  • 807
Loading
Notice removed Current answers are outdated by alvas
Bounty Ended with jfs's answer chosen by alvas
added 133 characters in body
Source Link
alvas
  • 123.4k
  • 118
  • 503
  • 807
Loading
Notice added Current answers are outdated by alvas
Bounty Started worth 50 reputation by alvas
Source Link
James Sulak
  • 32.6k
  • 11
  • 55
  • 58
Loading
Source Link
James Sulak
  • 32.6k
  • 11
  • 55
  • 58
Loading